Complete impletation

This commit is contained in:
zawz 2020-02-07 14:35:46 +01:00
parent cd02c525e5
commit edcc301640
5 changed files with 93 additions and 9 deletions

View file

@ -1,2 +1,42 @@
# zpkg
Simple and basic packaging system
Designed to be used by anyone and deployed anywhere,
it is a very basic packaging system without much functionnality but very portable
Official repo: `http://zawz.net/zpkg`
## Use as user
### Installing
```shell
curl -SO http://zawz.net/zpkg/install.sh
sh install.sh
```
If you wish to use another repository, substitute `zawz.net/zpkg` for your desired target
### Using
See `zpkg help`
## Deploy on a server
### Requirements
To deploy on a server you need:
- SSH server
- HTTP server
- dedicated zpkg user
You need to be able to SSH to the zpkg user. SSH keys are recommended
### Process
1. Write the desired config in `.config`, see `.config.example`
2. Run `server_deploy.sh`
3. Make available the package directory to the HTTP server

6
scripts/database_update.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
. "$(pwd)/.config"
cd "$HOME/$PKG_PATH" || exit $?
stat -c "%n %Y" ./*.tar.xz | sed 's|\.tar\.xz||g;s|^\./||g' > pkglist

39
scripts/gen_install.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
. "$(pwd)/.config"
# create install file
echo '#!/bin/sh
' > install.sh
grep -E "(^HTTP_)|(^PKG_PATH)" .config >> install.sh
echo '
# Generate conf file
mkdir -p /etc/zpkg || exit $?
{
echo "SSH_ADDRESS=$SSH_USER@$SSH_ADDR"
echo "HTTP_ADDRESS=$HTTP_ADDR/$HTTP_PATH"
echo "PKG_PATH=pkg"
} > /etc/zpkg/zpkg.conf
# download zpkg
mkdir -p tmp || exit $?
(
cd tmp || exit $?
if ! wget "$HTTP_ADDR/$HTTP_PATH/zpkg.tar.xz" -q -O "zpkg.tar.xz"
then
echo "Cannot reach $HTTP_ADDR/$HTTP_PATH" > /dev/stderr
exit 1
fi
tar xf zpkg.tar.xz || exit $?
# install zpkg package
usr/local/bin/zpkg install zpkg || exit $?
)
# cleanup
rm -rd tmp || exit $?
zpkg update-database >/dev/null || exit $?
' >> install.sh
mv install.sh "$HOME/$PKG_PATH"

View file

@ -17,10 +17,12 @@ mkdir -p "$DIR/$PKG$DEST" || exit $?
mkdir -p "$DIR/$PKG$BASHDEST" || exit $?
cp src/zpkg.bash "$ZPKG_PKG_PATH/$PKG$BASHDEST" || exit $?
cp src/zpkg "$ZPKG_PKG_PATH/$PKG$DEST" || exit $?
cd pkg/zpkg || exit $?
tar -cvJf zpkg.tar.xz * || exit $?
# send package
scp zpkg.tar.xz "$ssh":~/"$PKG_PATH" || exit $?
(
cd pkg/zpkg || exit $?
tar -cvJf zpkg.tar.xz * || exit $?
# send package
scp zpkg.tar.xz "$ssh":~/"$PKG_PATH" || exit $?
)
rm -rd "$DIR"
# update database
ssh "$ssh" sh database_update.sh || exit $?

View file

@ -82,7 +82,7 @@ deploy_package ()
fetch_package ()
{
if ! wget "$HTTP_ADDRESS/zpkg/$1.tar.xz" -q --show-progress -O "$1.tar.xz" 2>&1
if ! wget "$HTTP_ADDRESS/$1.tar.xz" -q --show-progress -O "$1.tar.xz" 2>&1
then
echo "Package '$1' not found" > /dev/stderr
return 1
@ -105,7 +105,7 @@ fetch_pkglist ()
{
cd "$config_path"
mv pkglist pkglist_bak 2>/dev/null
if ! wget "$HTTP_ADDRESS/zpkg/pkglist" -q --show-progress -O pkglist 2>&1
if ! wget "$HTTP_ADDRESS/pkglist" -q --show-progress -O pkglist 2>&1
then
echo "Couldn't fetch server data" > /dev/stderr
mv pkglist_bak pkglist 2>/dev/null
@ -216,9 +216,6 @@ fi
. "$config_file"
#ssh_address=$(grep "SSH_ADDRESS=" "$config_file" | cut -d '=' -f2-)
#http_address=$(grep "HTTP_ADDRESS=" "$config_file" | cut -d '=' -f2-)
#pkg_path=$(grep "PKG_PATH=" "$config_file" | cut -d '=' -f2-)
if [ "$(echo $PKG_PATH | cut -c1)" != "/" ]
then
PKG_PATH="$config_path/$PKG_PATH"