Fix install options

This commit is contained in:
zawz 2020-03-02 16:53:17 +01:00
parent ce4bf5ea95
commit 5be2abe9cc
4 changed files with 34 additions and 18 deletions

View file

@ -23,15 +23,11 @@ Optional:
wget http://zawz.net/zpkg/install.sh wget http://zawz.net/zpkg/install.sh
sh install.sh sh install.sh
``` ```
> By default the config is installed to /etc/zpkg > By default the config is installed to /etc/zpkg.
> This can be changed with the -c option
If you wish to use another repository, substitute `zawz.net/zpkg` for your desired target If you wish to use another repository, substitute `zawz.net/zpkg` for your desired target
#### Installing to a custom location
Add the -c option to the install script to specify a custom config path for the install
### Uninstalling ### Uninstalling
```shell ```shell

View file

@ -4,10 +4,11 @@
ssh="$SSH_USER@$SSH_ADDR" ssh="$SSH_USER@$SSH_ADDR"
DIR=tmp
PKG=zpkg random_string()
DEST=/usr/local/bin {
BASHDEST=/etc/bash_completion.d tr -cd '[:alnum:]' < /dev/urandom | head -c$1
}
# build # build
./compile.sh || exit $? ./compile.sh || exit $?
@ -16,7 +17,11 @@ BASHDEST=/etc/bash_completion.d
ssh "$ssh" mkdir -p "$PKG_PATH" || exit $? ssh "$ssh" mkdir -p "$PKG_PATH" || exit $?
scp .config server_scripts/* "$ssh":~/ || exit $? scp .config server_scripts/* "$ssh":~/ || exit $?
fullpath="$DIR/$PKG/ROOT" PKG=zpkg
DEST=/usr/local/bin
BASHDEST=/etc/bash_completion.d
tmpdir="/tmp/zpkg$(random_string 5)"
fullpath="$tmpdir/$PKG/ROOT"
# setup package sources # setup package sources
mkdir -p "$fullpath$DEST" || exit $? mkdir -p "$fullpath$DEST" || exit $?
mkdir -p "$fullpath$BASHDEST" || exit $? mkdir -p "$fullpath$BASHDEST" || exit $?
@ -24,13 +29,13 @@ cp completion/zpkg.bash "$fullpath$BASHDEST" || exit $?
mv zpkg "$fullpath$DEST" || exit $? mv zpkg "$fullpath$DEST" || exit $?
# create and send package # create and send package
( (
cd tmp/zpkg || exit $? cd "$tmpdir/$PKG" || exit $?
tar -cvJf zpkg.tar.xz * || exit $? tar -cvJf zpkg.tar.xz * || exit $?
# send package # send package
scp zpkg.tar.xz "$ssh":~/"$PKG_PATH" || exit $? scp zpkg.tar.xz "$ssh":~/"$PKG_PATH" || exit $?
) )
# cleanup # cleanup
rm -rd "$DIR" rm -rd "$tmpdir"
# update database # update database
ssh "$ssh" sh database_update.sh || exit $? ssh "$ssh" sh database_update.sh || exit $?
# generate install script # generate install script

View file

@ -11,6 +11,20 @@ cat .config >> install.sh
# body # body
echo ' echo '
usage()
{
echo "$(basename "$0")" [option...]
echo "
Options:
-h Show this help message
-c <path> Use this path as config"
}
random_string()
{
tr -cd '[:alnum:]' < /dev/urandom | head -c$1
}
config_path=/etc/zpkg config_path=/etc/zpkg
while getopts ":hc:" opt; while getopts ":hc:" opt;
@ -51,22 +65,23 @@ sudo mkdir -p "$config_path" || exit $?
sudo mv zpkg.conf "$config_path" || exit $? sudo mv zpkg.conf "$config_path" || exit $?
# download zpkg # download zpkg
mkdir -p tmp || exit $? tmpdir=/tmp/zpkg$(random_string 5)
mkdir -p "$tmpdir" || exit $?
( (
cd tmp || exit $? cd "$tmpdir" || exit $?
if ! wget "$HTTP_ADDR/$HTTP_PATH/zpkg.tar.xz" -q -O "zpkg.tar.xz" if ! wget "$HTTP_ADDR/$HTTP_PATH/zpkg.tar.xz" -q -O "zpkg.tar.xz"
then then
echo "Cannot reach $HTTP_ADDR/$HTTP_PATH" > /dev/stderr echo "Cannot reach $HTTP_ADDR/$HTTP_PATH" > /dev/stderr
exit 1 exit 1
fi fi
tar xf zpkg.tar.xz || exit $? tar -xf zpkg.tar.xz || exit $?
# install zpkg package # install zpkg package
ROOT/usr/local/bin/zpkg install zpkg || exit $? ROOT/usr/local/bin/zpkg install zpkg || exit $?
) )
# cleanup # cleanup
rm -rd tmp || exit $? rm -rd "$tmpdir" || exit $?
zpkg update-database >/dev/null || exit $? zpkg update-database >/dev/null || exit $?
' >> install.sh ' >> install.sh

View file

@ -21,7 +21,7 @@ Admin operations:
Options: Options:
-h Display this help -h Display this help
-c <path> Custom config path -c <path> Custom config path
-f Force run when root -f Force running even when root
' '
} }