diff --git a/README.md b/README.md index afe85f0..1cdc77d 100644 --- a/README.md +++ b/README.md @@ -23,15 +23,11 @@ Optional: wget http://zawz.net/zpkg/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 - -#### Installing to a custom location - -Add the -c option to the install script to specify a custom config path for the install - ### Uninstalling ```shell diff --git a/server_deploy.sh b/server_deploy.sh index 294d1bf..af16fde 100755 --- a/server_deploy.sh +++ b/server_deploy.sh @@ -4,10 +4,11 @@ ssh="$SSH_USER@$SSH_ADDR" -DIR=tmp -PKG=zpkg -DEST=/usr/local/bin -BASHDEST=/etc/bash_completion.d + +random_string() +{ + tr -cd '[:alnum:]' < /dev/urandom | head -c$1 +} # build ./compile.sh || exit $? @@ -16,7 +17,11 @@ BASHDEST=/etc/bash_completion.d ssh "$ssh" mkdir -p "$PKG_PATH" || 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 mkdir -p "$fullpath$DEST" || exit $? mkdir -p "$fullpath$BASHDEST" || exit $? @@ -24,13 +29,13 @@ cp completion/zpkg.bash "$fullpath$BASHDEST" || exit $? mv zpkg "$fullpath$DEST" || exit $? # create and send package ( - cd tmp/zpkg || exit $? + cd "$tmpdir/$PKG" || exit $? tar -cvJf zpkg.tar.xz * || exit $? # send package scp zpkg.tar.xz "$ssh":~/"$PKG_PATH" || exit $? ) # cleanup -rm -rd "$DIR" +rm -rd "$tmpdir" # update database ssh "$ssh" sh database_update.sh || exit $? # generate install script diff --git a/server_scripts/gen_install.sh b/server_scripts/gen_install.sh index d301841..0552b3f 100755 --- a/server_scripts/gen_install.sh +++ b/server_scripts/gen_install.sh @@ -11,6 +11,20 @@ cat .config >> install.sh # body echo ' +usage() +{ + echo "$(basename "$0")" [option...] + echo " +Options: + -h Show this help message + -c Use this path as config" +} + +random_string() +{ + tr -cd '[:alnum:]' < /dev/urandom | head -c$1 +} + config_path=/etc/zpkg while getopts ":hc:" opt; @@ -51,22 +65,23 @@ sudo mkdir -p "$config_path" || exit $? sudo mv zpkg.conf "$config_path" || exit $? # 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" then echo "Cannot reach $HTTP_ADDR/$HTTP_PATH" > /dev/stderr exit 1 fi - tar xf zpkg.tar.xz || exit $? + tar -xf zpkg.tar.xz || exit $? # install zpkg package ROOT/usr/local/bin/zpkg install zpkg || exit $? ) # cleanup -rm -rd tmp || exit $? +rm -rd "$tmpdir" || exit $? zpkg update-database >/dev/null || exit $? ' >> install.sh diff --git a/src/print.sh b/src/print.sh index d01a39c..661cba1 100644 --- a/src/print.sh +++ b/src/print.sh @@ -21,7 +21,7 @@ Admin operations: Options: -h Display this help -c Custom config path - -f Force run when root + -f Force running even when root ' }