SILENCE you fools!

This commit is contained in:
AJ ONeal 2018-06-28 14:47:32 -06:00
parent 0c924753c3
commit 2ae4b5a25a
1 changed files with 52 additions and 25 deletions

View File

@ -31,6 +31,8 @@ set -u
### http_bash exported by get.sh ### http_bash exported by get.sh
TELEBIT_DEBUG=${TELEBIT_DEBUG:-}
if [ "$(logname)" != "$(id -u -n)" ]; then if [ "$(logname)" != "$(id -u -n)" ]; then
echo "WARNING:" echo "WARNING:"
echo " You are logged in as '$(logname)' but acting as '$(id -u -n)'." echo " You are logged in as '$(logname)' but acting as '$(id -u -n)'."
@ -96,14 +98,14 @@ TELEBIT_REAL_PATH=${TELEBIT_PATH:-}
if [ $(id -u) -ne 0 ] && [ "$TELEBIT_USER" == "$cur_user" ]; then if [ $(id -u) -ne 0 ] && [ "$TELEBIT_USER" == "$cur_user" ]; then
TELEBIT_USERSPACE="yes" TELEBIT_USERSPACE="yes"
if [ -z "${TELEBIT_REAL_PATH:-}" ]; then if [ -z "${TELEBIT_REAL_PATH:-}" ]; then
echo 'TELEBIT_PATH="'${TELEBIT_REAL_PATH:-}'"'
TELEBIT_REAL_PATH=$HOME/Applications/$my_app TELEBIT_REAL_PATH=$HOME/Applications/$my_app
echo 'TELEBIT_PATH=""; using default: '${TELEBIT_REAL_PATH}
fi fi
else else
TELEBIT_USERSPACE="no" TELEBIT_USERSPACE="no"
if [ -z "${TELEBIT_REAL_PATH:-}" ]; then if [ -z "${TELEBIT_REAL_PATH:-}" ]; then
echo 'TELEBIT_PATH="'${TELEBIT_REAL_PATH:-}'"'
TELEBIT_REAL_PATH=/opt/$my_app TELEBIT_REAL_PATH=/opt/$my_app
echo 'TELEBIT_PATH=""; using default: '${TELEBIT_REAL_PATH}
fi fi
fi fi
TELEBIT_PATH="$TELEBIT_REAL_PATH" TELEBIT_PATH="$TELEBIT_REAL_PATH"
@ -113,7 +115,7 @@ TELEBIT_TMP="$TELEBIT_REAL_PATH"
my_tmp="$(mktemp -d -t telebit.XXXXXXXX)" my_tmp="$(mktemp -d -t telebit.XXXXXXXX)"
#TELEBIT_TMP="$my_tmp/telebit" #TELEBIT_TMP="$my_tmp/telebit"
echo "Installing $my_name to '$TELEBIT_REAL_PATH'" echo "Installing $my_name with 'TELEBIT_PATH=$TELEBIT_REAL_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"
NODEJS_VER="${NODEJS_VER:-v10.2}" NODEJS_VER="${NODEJS_VER:-v10.2}"
export NODEJS_VER export NODEJS_VER
@ -122,7 +124,6 @@ export NPM_CONFIG_PREFIX="$TELEBIT_TMP"
# this comes last for security # this comes last for security
export PATH="$PATH:$TELEBIT_REAL_PATH/bin" export PATH="$PATH:$TELEBIT_REAL_PATH/bin"
sleep 0.25 sleep 0.25
echo "(your password may be required to begin the installation)"
real_sudo_cmd=$soft_sudo_cmd real_sudo_cmd=$soft_sudo_cmd
real_sudo_cmde=$soft_sudo_cmde real_sudo_cmde=$soft_sudo_cmde
@ -139,8 +140,13 @@ fi
set -e set -e
if [ -n "${TELEBIT_DEBUG}" ]; then
echo " - installing node.js runtime to '$TELEBIT_REAL_PATH'..." echo " - installing node.js runtime to '$TELEBIT_REAL_PATH'..."
http_bash https://git.coolaj86.com/coolaj86/node-installer.sh/raw/branch/master/install.sh --no-dev-deps
else
echo -n "."
http_bash https://git.coolaj86.com/coolaj86/node-installer.sh/raw/branch/master/install.sh --no-dev-deps >/dev/null 2>/dev/null http_bash https://git.coolaj86.com/coolaj86/node-installer.sh/raw/branch/master/install.sh --no-dev-deps >/dev/null 2>/dev/null
fi
# #
# TODO create "upgrade" script and run that instead # TODO create "upgrade" script and run that instead
@ -160,7 +166,11 @@ my_tar=$(type -p tar)
# TODO extract to temporary directory, configure, copy etc, replace # TODO extract to temporary directory, configure, copy etc, replace
if [ -n "$my_unzip" ]; then if [ -n "$my_unzip" ]; then
rm -f $my_tmp/$my_app-$TELEBIT_VERSION.zip rm -f $my_tmp/$my_app-$TELEBIT_VERSION.zip
if [ -n "${TELEBIT_DEBUG}" ]; then
echo " - installing telebit zip to '$TELEBIT_REAL_PATH'..." echo " - installing telebit zip to '$TELEBIT_REAL_PATH'..."
else
echo -n "."
fi
http_get https://git.coolaj86.com/coolaj86/$my_repo/archive/$TELEBIT_VERSION.zip $my_tmp/$my_app-$TELEBIT_VERSION.zip http_get https://git.coolaj86.com/coolaj86/$my_repo/archive/$TELEBIT_VERSION.zip $my_tmp/$my_app-$TELEBIT_VERSION.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-$TELEBIT_VERSION.zip -d $my_tmp/ >/dev/null $my_unzip -o $my_tmp/$my_app-$TELEBIT_VERSION.zip -d $my_tmp/ >/dev/null
@ -168,7 +178,11 @@ if [ -n "$my_unzip" ]; then
rm -rf $my_tmp/$my_repo rm -rf $my_tmp/$my_repo
elif [ -n "$my_tar" ]; then elif [ -n "$my_tar" ]; then
rm -f $my_tmp/$my_app-$TELEBIT_VERSION.tar.gz rm -f $my_tmp/$my_app-$TELEBIT_VERSION.tar.gz
if [ -n "${TELEBIT_DEBUG}" ]; then
echo " - installing telebit tar.gz to '$TELEBIT_REAL_PATH'..." echo " - installing telebit tar.gz to '$TELEBIT_REAL_PATH'..."
else
echo -n "."
fi
http_get https://git.coolaj86.com/coolaj86/$my_repo/archive/$TELEBIT_VERSION.tar.gz $my_tmp/$my_app-$TELEBIT_VERSION.tar.gz http_get https://git.coolaj86.com/coolaj86/$my_repo/archive/$TELEBIT_VERSION.tar.gz $my_tmp/$my_app-$TELEBIT_VERSION.tar.gz
$my_tar -xzf $my_tmp/$my_app-$TELEBIT_VERSION.tar.gz --strip 1 -C $TELEBIT_TMP/ >/dev/null $my_tar -xzf $my_tmp/$my_app-$TELEBIT_VERSION.tar.gz --strip 1 -C $TELEBIT_TMP/ >/dev/null
else else
@ -181,8 +195,11 @@ set -e
# TODO create slim packages that contain all the deps on each os and cpu # TODO create slim packages that contain all the deps on each os and cpu
# #
pushd $TELEBIT_TMP >/dev/null pushd $TELEBIT_TMP >/dev/null
if [ -n "${TELEBIT_DEBUG}" ]; then
echo " - installing telebit npm dependencies to '$TELEBIT_REAL_PATH'..." echo " - installing telebit npm dependencies to '$TELEBIT_REAL_PATH'..."
echo " (are you noticing a pattern of where things are installed?)" else
echo -n "."
fi
$tmp_npm install >/dev/null 2>/dev/null $tmp_npm install >/dev/null 2>/dev/null
popd >/dev/null popd >/dev/null
@ -403,7 +420,11 @@ echo ""
if [ "launchd" == "$my_system_launcher" ]; then if [ "launchd" == "$my_system_launcher" ]; then
if [ "yes" == "$TELEBIT_USERSPACE" ]; then if [ "yes" == "$TELEBIT_USERSPACE" ]; then
if [ -n "${TELEBIT_DEBUG}" ]; then
echo " > launchctl load -w $my_app_launchd_service" echo " > launchctl load -w $my_app_launchd_service"
else
echo -n "."
fi
launchctl load -w "$my_app_launchd_service" launchctl load -w "$my_app_launchd_service"
else else
echo " > ${real_sudo_cmde}launchctl load -w $my_app_launchd_service" echo " > ${real_sudo_cmde}launchctl load -w $my_app_launchd_service"
@ -416,20 +437,22 @@ elif [ "systemd" == "$my_system_launcher" ]; then
# https://wiki.archlinux.org/index.php/Systemd/User # https://wiki.archlinux.org/index.php/Systemd/User
# sudo loginctl enable-linger username # sudo loginctl enable-linger username
if [ -n "${TELEBIT_DEBUG}" ]; then
echo " > systemctl --user enable $my_app" echo " > systemctl --user enable $my_app"
else
echo -n "."
fi
systemctl --user daemon-reload systemctl --user daemon-reload
systemctl --user enable $my_app >/dev/null systemctl --user enable $my_app >/dev/null
#echo " > systemctl --user enable systemd-tmpfiles-setup.service systemd-tmpfiles-clean.timer" #echo " > systemctl --user enable systemd-tmpfiles-setup.service systemd-tmpfiles-clean.timer"
#systemctl --user enable systemd-tmpfiles-setup.service systemd-tmpfiles-clean.timer #systemctl --user enable systemd-tmpfiles-setup.service systemd-tmpfiles-clean.timer
if [ -n "${TELEBIT_DEBUG}" ]; then
echo " > systemctl --user start $my_app" echo " > systemctl --user start $my_app"
systemctl --user daemon-reload fi
systemctl --user stop $my_app 2>/dev/null systemctl --user stop $my_app >/dev/null 2>/dev/null
systemctl --user start $my_app systemctl --user start $my_app >/dev/null
sleep 2 sleep 2
systemctl --user stop $my_app 2>/dev/null systemctl --user status --no-pager $my_app | grep "active.*running"
systemctl --user start $my_app
sleep 1
systemctl --user status --no-pager $my_app
else else
$real_sudo_cmd systemctl daemon-reload $real_sudo_cmd systemctl daemon-reload
@ -446,13 +469,15 @@ else
echo "Run the service manually (we couldn't detect your system service to do that automatically):" echo "Run the service manually (we couldn't detect your system service to do that automatically):"
echo "" echo ""
echo " $my_daemon --config $TELEBITD_CONFIG" echo " $TELEBITD_BIN --config $TELEBITD_CONFIG"
echo " $my_app --config $TELEBIT_CONFIG" echo " ~/$my_app --config $TELEBIT_CONFIG"
fi fi
# NOTE: ln -sf *should* replace an existing link... but sometimes it doesn't # NOTE: ln -sf *should* replace an existing link... but sometimes it doesn't
if [ -n "${TELEBIT_DEBUG}" ]; then
echo " > ${real_sudo_cmde}ln -sf $TELEBIT_REAL_PATH/bin/$my_app /usr/local/bin/$my_app" echo " > ${real_sudo_cmde}ln -sf $TELEBIT_REAL_PATH/bin/$my_app /usr/local/bin/$my_app"
fi
rm -f /usr/local/bin/$my_app || $real_sudo_cmd rm -f /usr/local/bin/$my_app rm -f /usr/local/bin/$my_app || $real_sudo_cmd rm -f /usr/local/bin/$my_app
ln -sf $TELEBIT_REAL_PATH/bin/$my_app /usr/local/bin/$my_app 2>/dev/null || true ln -sf $TELEBIT_REAL_PATH/bin/$my_app /usr/local/bin/$my_app 2>/dev/null || true
#\ $real_sudo_cmd ln -sf $TELEBIT_REAL_PATH/bin/$my_app /usr/local/bin/$my_app #\ $real_sudo_cmd ln -sf $TELEBIT_REAL_PATH/bin/$my_app /usr/local/bin/$my_app
@ -463,8 +488,10 @@ rm -f $HOME/$my_app; ln -s $TELEBIT_REAL_PATH/bin/$my_app $HOME/
# $real_sudo_cmd ln -sf $TELEBIT_REAL_PATH/bin/$my_daemon /usr/local/bin/$my_daemon # $real_sudo_cmd ln -sf $TELEBIT_REAL_PATH/bin/$my_daemon /usr/local/bin/$my_daemon
if [ -n "${TELEBIT_DEBUG}" ]; then
echo " > telebit init --tty" echo " > telebit init --tty"
echo "" echo ""
fi
sleep 0.25 sleep 0.25
$TELEBIT_REAL_PATH/bin/node $TELEBIT_REAL_PATH/bin/telebit.js init --tty $TELEBIT_REAL_PATH/bin/node $TELEBIT_REAL_PATH/bin/telebit.js init --tty