Fix self-update switch

This commit is contained in:
2024-10-18 21:04:42 -04:00
parent 6d548ac278
commit 3b492d309b

View File

@@ -68,7 +68,7 @@ print_help() {
--createrepo-user USER --createrepo-user USER
Specify the web server user if it differs from \$USER Specify the web server user if it differs from \$USER
--no-update --no-update
Disable automatic self-update Disable automatic installJRMCself-update
--uninstall, -u --uninstall, -u
Uninstall JRiver MC, remove services, containers, and firewall rules (does not remove library files) Uninstall JRiver MC, remove services, containers, and firewall rules (does not remove library files)
--yes, -y, --auto --yes, -y, --auto
@@ -145,6 +145,32 @@ init() {
# Reset DEBUG and recatch properly with getopt # Reset DEBUG and recatch properly with getopt
declare -g DEBUG=0 declare -g DEBUG=0
# Set defaults for no arguments or parse input
if [[ $# -eq 0 ]]; then
debug "Automatically setting --install repo"
REPO_INSTALL_SWITCH=1
# Skip getopt
else
# Set sane defaults for
if [[ $# -le 2 ]]; then
case "$1" in
--debug | -d | -y | --yes | --auto | --mcrepo | --mcversion | \
--arch | --betapass | --restorefile | --outputdir | --no-update)
if [[ $ID != "unknown" ]]; then
debug "Automatically setting --install repo"
REPO_INSTALL_SWITCH=1
fi
;;
--compat)
if [[ $# -eq 1 ]]; then
BUILD_SWITCH=1
LOCAL_INSTALL_SWITCH=1
fi
;;
esac
fi
if input=$(getopt -o $short_opts -l $long_opts -- "$@"); then if input=$(getopt -o $short_opts -l $long_opts -- "$@"); then
eval set -- "$input" eval set -- "$input"
while true; do while true; do
@@ -197,6 +223,8 @@ init() {
print_help && exit 1 print_help && exit 1
fi fi
fi
# Get host information # Get host information
[[ -f /etc/os-release ]] && source /etc/os-release [[ -f /etc/os-release ]] && source /etc/os-release
@@ -242,27 +270,7 @@ init() {
fi fi
esac esac
# Set some defaults if zero or one arguments are passed
if [[ $# -eq 0 && $ID != "unknown" ]]; then
debug "Automatically setting --install repo"
REPO_INSTALL_SWITCH=1
elif [[ $# -eq 1 || $# -eq 2 ]]; then
case "$1" in
--debug | -d | -y | --yes | --auto | --mcrepo | --mcversion | \
--arch | --betapass | --restorefile | --outputdir | --no-self-update)
if [[ $ID != "unknown" ]]; then
debug "Automatically setting --install repo"
REPO_INSTALL_SWITCH=1
fi
;;
--compat)
if [[ $# -eq 1 ]]; then
BUILD_SWITCH=1
LOCAL_INSTALL_SWITCH=1
fi
;;
esac
fi
# Set default targets # Set default targets
BUILD_TARGET="${BUILD_TARGET:-$ID}" BUILD_TARGET="${BUILD_TARGET:-$ID}"
@@ -1469,7 +1477,7 @@ update() {
after_pull_hash=$(git -C "$SCRIPT_DIR" rev-parse HEAD) after_pull_hash=$(git -C "$SCRIPT_DIR" rev-parse HEAD)
if [[ "$before_pull_hash" != "$after_pull_hash" ]]; then if [[ "$before_pull_hash" != "$after_pull_hash" ]]; then
echo "installJRMC repository updated. Restarting script..." echo "installJRMC repository updated. Restarting script..."
exec "$SCRIPT_PATH" "$@" "--no-self-update" exec "$SCRIPT_PATH" "$@" "--no-update"
fi fi
fi fi
@@ -1493,7 +1501,7 @@ update() {
echo "Updating installJRMC $SCRIPT_VERSION to $remote_version" echo "Updating installJRMC $SCRIPT_VERSION to $remote_version"
execute mv "$tmp" "$SCRIPT_PATH" execute mv "$tmp" "$SCRIPT_PATH"
execute chmod +x "$SCRIPT_PATH" execute chmod +x "$SCRIPT_PATH"
exec "$SCRIPT_PATH" "$@" "--no-self-update" exec "$SCRIPT_PATH" "$@" "--no-update"
fi fi
rm -f "$tmp" rm -f "$tmp"