Skip to content

Commit 234fb71

Browse files
authored
Update upgrade.sh: Add --skip
Also: check if $ALLSKY_HOME exists before restoring directories
1 parent f65c9cc commit 234fb71

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

upgrade.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ source "${ALLSKY_SCRIPTS}/installUpgradeFunctions.sh" || exit "${ALLSKY_EXIT_ERR
1919
# - Don't prompt to reboot
2020
# - Don't prompt other things ??
2121
#
22-
#############
23-
# TODO:
24-
# Check for symbolic links
25-
#############
2622

2723
# shellcheck disable=SC2034
2824
DISPLAY_MSG_LOG="${ALLSKY_LOGS}/upgrade.log" # send log entries here
@@ -110,12 +106,20 @@ function check_for_oldest()
110106

111107
function restore_directories()
112108
{
109+
if [[ -d ${ALLSKY_HOME} ]]; then
110+
local MSG="Cannot restore directories: '${ALLSKY_HOME}' already exists."
111+
display_msg --log warning "${MSG}"
112+
return 1
113+
fi
114+
113115
display_msg --log info "Renaming '${ALLSKY_PRIOR_DIR}' back to '${ALLSKY_HOME}'."
114116
mv "${ALLSKY_PRIOR_DIR}" "${ALLSKY_HOME}"
115117
if [[ -d ${OLDEST_DIR} ]]; then
116118
display_msg --log info "Renaming '${OLDEST_DIR}' back to '${ALLSKY_PRIOR_DIR}'."
117119
mv "${OLDEST_DIR}" "${ALLSKY_PRIOR_DIR}"
118120
fi
121+
122+
return 0
119123
}
120124

121125

@@ -126,7 +130,7 @@ function usage_and_exit()
126130
exec >&2
127131

128132
echo
129-
local USAGE="Usage: ${ME} [--help] [--debug] [--branch branch] [--doUpgrade] [--in-place]"
133+
local USAGE="Usage: ${ME} [--help] [--debug] [--branch branch] [--doUpgrade] [--in-place] [--skip]"
130134
if [[ ${RET} -eq 0 ]]; then
131135
echo "Upgrade the Allsky software to a newer version."
132136
echo -e "\n${USAGE}"
@@ -139,6 +143,7 @@ function usage_and_exit()
139143
echo " --branch branch Uses 'branch' instead of the production '${ALLSKY_GITHUB_MAIN_BRANCH}' branch."
140144
echo " --doUpgrade Completes the upgrade."
141145
echo " --in-place Specifies an 'in-place' upgrade should be performed."
146+
echo " --skip Tells install.sh to skip some steps."
142147
echo
143148
exit "${RET}"
144149
}
@@ -155,6 +160,7 @@ CHOSEN_METHOD=""
155160
OK="true"
156161
HELP="false"
157162
DEBUG="false"; DEBUG_ARG=""
163+
SKIP=""
158164
# shellcheck disable=SC2119
159165
BRANCH="$( get_branch )"
160166
[[ -z ${BRANCH} ]] && BRANCH="${ALLSKY_GITHUB_MAIN_BRANCH}"
@@ -181,6 +187,9 @@ while [[ $# -gt 0 ]]; do
181187
--in-place)
182188
CHOSEN_METHOD="${METHOD_IN_PLACE}"
183189
;;
190+
--skip)
191+
SKIP="${ARG}"
192+
;;
184193
-*)
185194
E_ "Unknown argument: '${ARG}'." >&2
186195
OK="false"
@@ -369,21 +378,23 @@ fi
369378
# --doUpgrade tells it to use prior version without asking and to not display header,
370379
# change messages to say "upgrade", not "install", etc.
371380
if false; then # XXXXXXXXXX TODO: FIX
381+
MSG="The first step of the upgrade is complete.\n"
382+
display_msg --log progress "${MSG}" " Running install.sh"
383+
display_msg --logonly info "ENDING UPGRADE; calling install.sh"
372384
# shellcheck disable=SC2086,SC2291
373385
X="$(
374386
#shellcheck disable=SC2116 # XXXXXXXXX temporary
375-
echo XXX ./install.sh ${DEBUG_ARG} --branch "${BRANCH}" --doUpgrade
387+
echo XXX ./install.sh ${DEBUG_ARG} --branch "${BRANCH}" ${SKIP} --doUpgrade
376388
)"
377389
RET=$?
378-
display_msg --logonly info "ENDING UPGRADE."
379390
if [[ ${RET} -ne 0 ]]; then
380391
display_msg --log warning "install.sh failed." "Contact the Allsky Team"
381392
exit "${RET}"
382393
fi
383394
display_msg --log progress "The upgrade is complete." " Go to the WebUI to restart Allsky.\n"
384395
else # XXXXXXXXXXX
385396
display_msg --log progress "The first step of the upgrade is complete.\n"
386-
MSG="cd ~/allsky; ./install.sh ${DEBUG_ARG}"
397+
MSG="cd ~/allsky; ./install.sh ${DEBUG_ARG} ${SKIP}"
387398
[[ ${BRANCH} != "${ALLSKY_GITHUB_MAIN_BRANCH}" ]] && MSG+=" --branch ${BRANCH}"
388399
display_msg --log note "Now run:" " ${MSG}\n"
389400
fi

0 commit comments

Comments
 (0)