Add rerun()
This commit is contained in:
35
installJRMC
35
installJRMC
@@ -236,13 +236,10 @@ init() {
|
|||||||
declare -g USER
|
declare -g USER
|
||||||
declare -g SCRIPT_PATH; SCRIPT_PATH=$(readlink -f "${BASH_SOURCE[0]}")
|
declare -g SCRIPT_PATH; SCRIPT_PATH=$(readlink -f "${BASH_SOURCE[0]}")
|
||||||
declare -g SCRIPT_DIR; SCRIPT_DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
|
declare -g SCRIPT_DIR; SCRIPT_DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
|
||||||
|
declare -gi SCRIPT_IS_PIPED=0
|
||||||
|
|
||||||
# Detect if script is being piped (SCRIPT_PATH won't be a regular file)
|
# Detect if script is being piped (SCRIPT_PATH won't be a regular file)
|
||||||
if [[ ! -f $SCRIPT_PATH ]]; then
|
[[ ! -f $SCRIPT_PATH ]] && SCRIPT_IS_PIPED=1
|
||||||
declare -g SCRIPT_IS_PIPED=1
|
|
||||||
else
|
|
||||||
declare -g SCRIPT_IS_PIPED=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -g OUTPUT_DIR="$SCRIPT_DIR/output"
|
declare -g OUTPUT_DIR="$SCRIPT_DIR/output"
|
||||||
declare -g CREATEREPO_WEBROOT="/var/www/jriver"
|
declare -g CREATEREPO_WEBROOT="/var/www/jriver"
|
||||||
@@ -265,7 +262,7 @@ init() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the self-updater if enabled
|
# Run the self-updater if enabled
|
||||||
((SELF_UPDATE_SWITCH)) && update "$@"
|
((SELF_UPDATE_SWITCH)) && ((! SCRIPT_IS_PIPED)) && update "$@"
|
||||||
|
|
||||||
# Check that the .jriver directory is owned by the user
|
# Check that the .jriver directory is owned by the user
|
||||||
((YES_SWITCH)) || fix_permissions "$HOME/.jriver" "$USER"
|
((YES_SWITCH)) || fix_permissions "$HOME/.jriver" "$USER"
|
||||||
@@ -1054,7 +1051,7 @@ install_mc_deb() {
|
|||||||
execute sudo rm -f "$temp_deb"
|
execute sudo rm -f "$temp_deb"
|
||||||
if ask_ok "Remove source DEB and retry?"; then
|
if ask_ok "Remove source DEB and retry?"; then
|
||||||
execute sudo rm -f "$MC_DEB"
|
execute sudo rm -f "$MC_DEB"
|
||||||
exec bash "$SCRIPT_PATH" "$@" "--no-update"
|
rerun "$@"
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -1716,7 +1713,7 @@ update() {
|
|||||||
# If the commit hash has changed, an update occurred
|
# If the commit hash has changed, an update occurred
|
||||||
if [[ "$before_pull_hash" != $(git -C "$SCRIPT_DIR" rev-parse HEAD) ]]; then
|
if [[ "$before_pull_hash" != $(git -C "$SCRIPT_DIR" rev-parse HEAD) ]]; then
|
||||||
echo "Detected installJRMC update, restarting"
|
echo "Detected installJRMC update, restarting"
|
||||||
exec bash "$SCRIPT_PATH" "$@" "--no-update"
|
rerun "$@"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
debug "Not in the installJRMC repository, checking for installJRMC update via webscrape."
|
debug "Not in the installJRMC repository, checking for installJRMC update via webscrape."
|
||||||
@@ -1747,7 +1744,7 @@ update() {
|
|||||||
execute rm -f "$tmp"
|
execute rm -f "$tmp"
|
||||||
|
|
||||||
echo "Detected installJRMC update, restarting"
|
echo "Detected installJRMC update, restarting"
|
||||||
exec bash "$SCRIPT_PATH" "$@" "--no-update"
|
rerun "$@"
|
||||||
else
|
else
|
||||||
debug "Current installJRMC $SCRIPT_VERSION is the latest version"
|
debug "Current installJRMC $SCRIPT_VERSION is the latest version"
|
||||||
execute rm -f "$tmp"
|
execute rm -f "$tmp"
|
||||||
@@ -1846,13 +1843,7 @@ main() {
|
|||||||
[[ -n $LEGACY_REPO_FILE ]] && sudo rm -f "$LEGACY_REPO_FILE"
|
[[ -n $LEGACY_REPO_FILE ]] && sudo rm -f "$LEGACY_REPO_FILE"
|
||||||
if [[ $MC_REPO != "$MC_REPO_HARDCODE" ]]; then
|
if [[ $MC_REPO != "$MC_REPO_HARDCODE" ]]; then
|
||||||
echo "Rerunning installJRMC with --mcrepo=$MC_REPO_HARDCODE"
|
echo "Rerunning installJRMC with --mcrepo=$MC_REPO_HARDCODE"
|
||||||
if ((SCRIPT_IS_PIPED)); then
|
rerun "$@" "--mcrepo=$MC_REPO_HARDCODE"
|
||||||
# Re-download and execute if script was piped
|
|
||||||
curl -fsSL "$SCRIPT_URL" | bash -s -- "$@" "--no-update" "--mcrepo=$MC_REPO_HARDCODE"
|
|
||||||
exit $?
|
|
||||||
else
|
|
||||||
exec bash "$SCRIPT_PATH" "$@" "--no-update" "--mcrepo=$MC_REPO_HARDCODE"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -2030,6 +2021,16 @@ create_mc_apt_container() {
|
|||||||
buildah run "$CNT" -- sh -c "$cmd" || { err "$cmd failed"; return 1; }
|
buildah run "$CNT" -- sh -c "$cmd" || { err "$cmd failed"; return 1; }
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
rerun() {
|
||||||
|
debug "${FUNCNAME[0]}()" "$@"
|
||||||
|
if ((SCRIPT_IS_PIPED)); then
|
||||||
|
# Re-download and execute if script was piped
|
||||||
|
curl -fsSL "$SCRIPT_URL" | bash -s -- "$@" "--no-update"
|
||||||
|
exit $?
|
||||||
|
else
|
||||||
|
exec bash "$SCRIPT_PATH" "$@" "--no-update"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Roughly turn debugging on for pre-init
|
# Roughly turn debugging on for pre-init
|
||||||
# Reset and reparse in parse_input() with getopt
|
# Reset and reparse in parse_input() with getopt
|
||||||
|
|||||||
Reference in New Issue
Block a user