installer is working as expected

This commit is contained in:
AJ ONeal 2018-05-25 01:08:38 +00:00
parent 127296fd5e
commit 4b38c27a71
1 changed files with 21 additions and 21 deletions

View File

@ -81,6 +81,8 @@ if [ -z "${my_email}" ]; then
echo "please enter your email." echo "please enter your email."
echo "" echo ""
read -p "email: " my_email read -p "email: " my_email
echo ""
sleep 2
fi fi
if [ -z "${TELEBITD_PATH:-}" ]; then if [ -z "${TELEBITD_PATH:-}" ]; then
@ -89,7 +91,6 @@ if [ -z "${TELEBITD_PATH:-}" ]; then
fi fi
echo "Installing $my_name to '$TELEBITD_PATH'" echo "Installing $my_name to '$TELEBITD_PATH'"
echo ""
echo "Installing node.js dependencies into $TELEBITD_PATH" echo "Installing node.js dependencies into $TELEBITD_PATH"
# v10.2+ has much needed networking fixes, but breaks ursa. v9.x has severe networking bugs. v8.x has working ursa, but requires tls workarounds" # v10.2+ has much needed networking fixes, but breaks ursa. v9.x has severe networking bugs. v8.x has working ursa, but requires tls workarounds"
@ -107,9 +108,6 @@ my_npm="$my_node $TELEBITD_PATH/bin/npm"
my_tmp="$TELEBITD_PATH/tmp" my_tmp="$TELEBITD_PATH/tmp"
mkdir -p $my_tmp mkdir -p $my_tmp
echo "Installing $my_name into $TELEBITD_PATH"
echo ""
echo "sudo mkdir -p '$TELEBITD_PATH'" echo "sudo mkdir -p '$TELEBITD_PATH'"
sudo mkdir -p "$TELEBITD_PATH" sudo mkdir -p "$TELEBITD_PATH"
echo "sudo mkdir -p '/etc/$my_user/'" echo "sudo mkdir -p '/etc/$my_user/'"
@ -125,7 +123,7 @@ if [ -n "$my_unzip" ]; then
rm -f $my_tmp/$my_app-$my_tree.zip rm -f $my_tmp/$my_app-$my_tree.zip
http_get https://git.coolaj86.com/coolaj86/$my_repo/archive/$my_tree.zip $my_tmp/$my_app-$my_tree.zip http_get https://git.coolaj86.com/coolaj86/$my_repo/archive/$my_tree.zip $my_tmp/$my_app-$my_tree.zip
# -o means overwrite, and there is no option to strip # -o means overwrite, and there is no option to strip
$my_unzip -o $my_tmp/$my_app-$my_tree.zip -d $TELEBITD_PATH/ > /dev/null $my_unzip -o $my_tmp/$my_app-$my_tree.zip -d $TELEBITD_PATH/ > /dev/null 2>&1
cp -ar $TELEBITD_PATH/$my_repo/* $TELEBITD_PATH/ > /dev/null cp -ar $TELEBITD_PATH/$my_repo/* $TELEBITD_PATH/ > /dev/null
rm -rf $TELEBITD_PATH/$my_bin rm -rf $TELEBITD_PATH/$my_bin
elif [ -n "$my_tar" ]; then elif [ -n "$my_tar" ]; then
@ -148,28 +146,24 @@ cat << EOF > $TELEBITD_PATH/bin/$my_app
$my_node $TELEBITD_PATH/bin/$my_bin $my_node $TELEBITD_PATH/bin/$my_bin
EOF EOF
chmod a+x $TELEBITD_PATH/bin/$my_app chmod a+x $TELEBITD_PATH/bin/$my_app
echo "Creating link to '$my_app' in /usr/local/bin"
echo "sudo ln -sf $TELEBITD_PATH/bin/$my_app /usr/local/bin/$my_app" echo "sudo ln -sf $TELEBITD_PATH/bin/$my_app /usr/local/bin/$my_app"
sudo ln -sf $TELEBITD_PATH/bin/$my_app /usr/local/bin/$my_app sudo ln -sf $TELEBITD_PATH/bin/$my_app /usr/local/bin/$my_app
set +e set +e
if type -p setcap >/dev/null 2>&1; then if type -p setcap >/dev/null 2>&1; then
echo "" #echo "Setting permissions to allow $my_app to run on port 80 and port 443 without sudo or root"
echo "Setting permissions to allow $my_app to run on port 80 and port 443 without sudo or root"
echo "sudo setcap cap_net_bind_service=+ep $TELEBITD_PATH/bin/node" echo "sudo setcap cap_net_bind_service=+ep $TELEBITD_PATH/bin/node"
sudo setcap cap_net_bind_service=+ep $TELEBITD_PATH/bin/node sudo setcap cap_net_bind_service=+ep $TELEBITD_PATH/bin/node
fi fi
set -e set -e
if [ -z "$(cat /etc/passwd | grep $my_user)" ]; then if [ -z "$(cat /etc/passwd | grep $my_user)" ]; then
echo ""
echo "### Adding user $my_app"
echo "sudo adduser --home $TELEBITD_PATH --gecos '' --disabled-password $my_user" echo "sudo adduser --home $TELEBITD_PATH --gecos '' --disabled-password $my_user"
sudo adduser --home $TELEBITD_PATH --gecos '' --disabled-password $my_user >/dev/null 2>&1 sudo adduser --home $TELEBITD_PATH --gecos '' --disabled-password $my_user >/dev/null 2>&1
fi fi
if [ ! -f "/etc/$my_user/$my_app.yml" ]; then if [ ! -f "/etc/$my_user/$my_app.yml" ]; then
echo "Creating config file from template. sudo may be required" echo "### Creating config file from template. sudo may be required"
#echo "sudo rsync -a examples/$my_app.yml /etc/$my_user/$my_app.yml" #echo "sudo rsync -a examples/$my_app.yml /etc/$my_user/$my_app.yml"
sudo bash -c "echo 'email: $my_email' >> /etc/$my_user/$my_app.yml" sudo bash -c "echo 'email: $my_email' >> /etc/$my_user/$my_app.yml"
sudo bash -c "echo 'secret: $my_secret' >> /etc/$my_user/$my_app.yml" sudo bash -c "echo 'secret: $my_secret' >> /etc/$my_user/$my_app.yml"
@ -187,10 +181,16 @@ sudo systemctl daemon-reload
echo "sudo systemctl enable $my_app" echo "sudo systemctl enable $my_app"
sudo systemctl enable $my_app sudo systemctl enable $my_app
echo "sudo systemctl start $my_app" echo "sudo systemctl start $my_app"
sudo systemctl start $my_app sudo systemctl restart $my_app
sleep 1
echo "" echo ""
echo "" echo ""
echo ""
echo "=============================================="
echo " Privacy Settings in Config"
echo "=============================================="
echo ""
echo "The example config file /etc/telebit/telebitd.yml opts-in to" echo "The example config file /etc/telebit/telebitd.yml opts-in to"
echo "contributing telemetrics and receiving infrequent relevant updates" echo "contributing telemetrics and receiving infrequent relevant updates"
echo "(probably once per quarter or less) such as important notes on" echo "(probably once per quarter or less) such as important notes on"
@ -198,23 +198,23 @@ echo "a new release, an important API change, etc. No spam."
echo "" echo ""
echo "Please edit the config file to meet your needs before starting." echo "Please edit the config file to meet your needs before starting."
echo "" echo ""
sleep 2
echo "" echo ""
echo "" echo ""
echo "===================================" echo "=============================================="
echo "Installed successfully. Last steps:" echo "Installed successfully. Last steps:"
echo "===================================" echo "=============================================="
echo "" echo ""
echo "Edit the config, if desired:" echo "Edit the config and restart, if desired:"
echo "" echo ""
echo " sudo vim /etc/telebit/telebitd.yml" echo " sudo vim /etc/telebit/telebitd.yml"
echo " sudo systemctl restart $my_app"
echo "" echo ""
echo "Enabled and start the service:" echo "Or disabled the service and start manually:"
echo ""
echo " sudo systemctl enable $my_app"
echo " sudo systemctl start $my_app"
echo ""
echo "Or run manually:"
echo "" echo ""
echo " sudo systemctl stop $my_app"
echo " sudo systemctl disable $my_app"
echo " $my_app --config /etc/$my_user/$my_app.yml" echo " $my_app --config /etc/$my_user/$my_app.yml"
echo "" echo ""
sleep 1