Change server config
This commit is contained in:
parent
572ca12e64
commit
8ea223fe93
3 changed files with 18 additions and 27 deletions
|
|
@ -1,16 +1,14 @@
|
||||||
# zpkg server config
|
# zpkg server config
|
||||||
|
|
||||||
# address of the SSH server
|
|
||||||
SSH_ADDR=example.com
|
|
||||||
# user for the SSH server
|
|
||||||
SSH_USER=zpkg
|
|
||||||
# path to packages for the zpkg user
|
|
||||||
PKG_PATH=pkg
|
|
||||||
|
|
||||||
# public address of the HTTP server
|
# public address of the HTTP server
|
||||||
HTTP_ADDR=example.com
|
HTTP_ADDRESS=http://example.com
|
||||||
# path on server
|
|
||||||
HTTP_PATH=zpkg
|
# address of the SSH server
|
||||||
|
SSH_ADDRESS=user@example.com
|
||||||
|
|
||||||
|
# path to packages for the zpkg user
|
||||||
|
# this is the target folder available at the HTTP_ADDRESS
|
||||||
|
PKG_PATH=pkg
|
||||||
|
|
||||||
# Compression to use for packages
|
# Compression to use for packages
|
||||||
# format:
|
# format:
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
. "$(pwd)/.config"
|
. "$(pwd)/.config"
|
||||||
|
|
||||||
ssh="$SSH_USER@$SSH_ADDR"
|
|
||||||
|
|
||||||
[ -z "$COMPRESSION" ] && COMPRESSION="xz:xz:pxz"
|
[ -z "$COMPRESSION" ] && COMPRESSION="xz:xz:pxz"
|
||||||
extension=$(echo "$COMPRESSION" | cut -d':' -f1)
|
extension=$(echo "$COMPRESSION" | cut -d':' -f1)
|
||||||
compress=$(echo "$COMPRESSION" | cut -d':' -f2)
|
compress=$(echo "$COMPRESSION" | cut -d':' -f2)
|
||||||
|
|
@ -21,8 +19,8 @@ random_string()
|
||||||
./compile.sh || exit $?
|
./compile.sh || exit $?
|
||||||
|
|
||||||
# add sources to server
|
# add sources to server
|
||||||
ssh "$ssh" mkdir -p "$PKG_PATH" || exit $?
|
ssh "$SSH_ADDRESS" mkdir -p "$PKG_PATH" || exit $?
|
||||||
scp .config server_scripts/* "$ssh":~/ || exit $?
|
scp .config server_scripts/* "$SSH_ADDRESS":~/ || exit $?
|
||||||
|
|
||||||
PKG=zpkg
|
PKG=zpkg
|
||||||
DEST=/usr/local/bin
|
DEST=/usr/local/bin
|
||||||
|
|
@ -39,11 +37,11 @@ mv zpkg "$fullpath$DEST" || exit $?
|
||||||
cd "$tmpdir/$PKG" || exit $?
|
cd "$tmpdir/$PKG" || exit $?
|
||||||
tar -cf - * | $pcompress > zpkg.tar.$extension || exit $?
|
tar -cf - * | $pcompress > zpkg.tar.$extension || exit $?
|
||||||
# send package
|
# send package
|
||||||
scp zpkg.tar.$extension "$ssh":~/"$PKG_PATH" || exit $?
|
scp zpkg.tar.$extension "$SSH_ADDRESS":~/"$PKG_PATH" || exit $?
|
||||||
)
|
)
|
||||||
# cleanup
|
# cleanup
|
||||||
rm -rd "$tmpdir"
|
rm -rd "$tmpdir"
|
||||||
# update database
|
# update database
|
||||||
ssh "$ssh" sh database_update.sh zpkg || exit $?
|
ssh "$SSH_ADDRESS" sh database_update.sh zpkg || exit $?
|
||||||
# generate install script
|
# generate install script
|
||||||
ssh "$ssh" sh gen_install.sh || exit $?
|
ssh "$SSH_ADDRESS" sh gen_install.sh || exit $?
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,6 @@ Options:
|
||||||
-c <path> Use this path as config"
|
-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;
|
||||||
|
|
@ -71,8 +66,8 @@ fi
|
||||||
|
|
||||||
# Generate conf file
|
# Generate conf file
|
||||||
$sudo sh -c "{
|
$sudo sh -c "{
|
||||||
echo SSH_ADDRESS=$SSH_USER@$SSH_ADDR
|
echo SSH_ADDRESS=$SSH_ADDRESS
|
||||||
echo HTTP_ADDRESS=$HTTP_ADDR/$HTTP_PATH
|
echo HTTP_ADDRESS=$HTTP_ADDRESS
|
||||||
echo COMPRESSION=$COMPRESSION
|
echo COMPRESSION=$COMPRESSION
|
||||||
echo PKG_PATH=pkg
|
echo PKG_PATH=pkg
|
||||||
} > zpkg.conf"
|
} > zpkg.conf"
|
||||||
|
|
@ -82,13 +77,13 @@ $sudo mkdir -p "$config_path" || exit $?
|
||||||
$sudo mv zpkg.conf "$config_path" || exit $?
|
$sudo mv zpkg.conf "$config_path" || exit $?
|
||||||
|
|
||||||
# download zpkg
|
# download zpkg
|
||||||
tmpdir=/tmp/zpkg$(random_string 5)
|
tmpdir=/tmp/zpkg$(tr -cd "[:alnum:]" < /dev/urandom | head -c5)
|
||||||
mkdir -p "$tmpdir" || exit $?
|
mkdir -p "$tmpdir" || exit $?
|
||||||
(
|
(
|
||||||
cd "$tmpdir" || exit $?
|
cd "$tmpdir" || exit $?
|
||||||
if ! wget "$HTTP_ADDR/$HTTP_PATH/zpkg.tar.$extension" -q -O "zpkg.tar.$extension"
|
if ! wget "$HTTP_ADDRESS/zpkg.tar.$extension" -q -O "zpkg.tar.$extension"
|
||||||
then
|
then
|
||||||
echo "Cannot reach $HTTP_ADDR/$HTTP_PATH" > /dev/stderr
|
echo "Cannot reach $HTTP_ADDRESS" > /dev/stderr
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
$pcompress -dc "zpkg.tar.$extension" | tar -xf - || exit $?
|
$pcompress -dc "zpkg.tar.$extension" | tar -xf - || exit $?
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue