Commit 782f9c4d by Ned Batchelder

Add logging, make minor cleanups

parent fcc07d6a
...@@ -3,28 +3,44 @@ ...@@ -3,28 +3,44 @@
# Stop if any command fails # Stop if any command fails
set -e set -e
# Logging: write all the output to a timestamped log file.
sudo mkdir -p /var/log/edx
exec > >(sudo tee /var/log/edx/upgrade-$(date +%Y%m%d-%H%M%S).log) 2>&1
# defaults # defaults
CONFIGURATION="none" CONFIGURATION="none"
TARGET="none" TARGET="none"
INTERACTIVE=true INTERACTIVE=true
OPENEDX_ROOT="/edx" OPENEDX_ROOT="/edx"
# Use this function to exit the script: it helps keep the output right with the
# exec-logging we started above.
exit_cleanly () {
sleep .25
echo
exit $@
}
show_help () { show_help () {
cat <<- EOM cat << EOM
Migrates your Open edX installation to a different release. Upgrades your Open edX installation to a newer release.
-c CONFIGURATION -c CONFIGURATION
Use the given configuration. Either \"devstack\" or \"fullstack\". You Use the given configuration. Either "devstack" or "fullstack". You
must specify this. must specify this.
-t TARGET -t TARGET
Migrate to the given git ref. You must specify this. Named releases are Upgrade to the given git ref. You must specify this. Named releases are
called \"named-release/cypress\", \"named-release/dogwood.rc2\", and so on. called "named-release/cypress", "named-release/dogwood.rc2", and so on.
-y -y
Run in non-interactive mode (reply \"yes\" to all questions) Run in non-interactive mode (reply "yes" to all questions)
-r OPENEDX_ROOT -r OPENEDX_ROOT
The root directory under which all Open edX applications are installed. The root directory under which all Open edX applications are installed.
Defaults to \"$OPENEDX_ROOT\" Defaults to "$OPENEDX_ROOT"
-h -h
Show this help and exit. Show this help and exit.
...@@ -36,7 +52,7 @@ while getopts "hc:t:y" opt; do ...@@ -36,7 +52,7 @@ while getopts "hc:t:y" opt; do
case "$opt" in case "$opt" in
h) h)
show_help show_help
exit 0 exit_cleanly 0
;; ;;
c) c)
CONFIGURATION=$OPTARG CONFIGURATION=$OPTARG
...@@ -59,14 +75,14 @@ confirm_proceed () { ...@@ -59,14 +75,14 @@ confirm_proceed () {
read input read input
if [[ "$input" != "yes" && "$input" != "y" ]]; then if [[ "$input" != "yes" && "$input" != "y" ]]; then
echo "Quitting" echo "Quitting"
exit 1 exit_cleanly 1
fi fi
} }
# Check we are in the right place, and have the info we need. # Check we are in the right place, and have the info we need.
if [[ ! -d /edx/app/edxapp ]]; then if [[ ! -d /edx/app/edxapp ]]; then
echo "Run this on your Open edX machine." echo "Run this on your Open edX machine."
exit 1 exit_cleanly 1
fi fi
if [[ $TARGET == none ]]; then if [[ $TARGET == none ]]; then
...@@ -76,12 +92,12 @@ you are currently running. This script can only move forward one release at ...@@ -76,12 +92,12 @@ you are currently running. This script can only move forward one release at
a time. a time.
EOM EOM
show_help show_help
exit 1 exit_cleanly 1
fi fi
if [[ $CONFIGURATION == none ]]; then if [[ $CONFIGURATION == none ]]; then
echo "You must specify a configuration, either fullstack or devstack." echo "You must specify a configuration, either fullstack or devstack."
exit 1 exit_cleanly 1
fi fi
APPUSER=edxapp APPUSER=edxapp
...@@ -269,4 +285,4 @@ fi ...@@ -269,4 +285,4 @@ fi
cd / cd /
sudo rm -rf $TEMPDIR sudo rm -rf $TEMPDIR
echo "Migration complete. Please reboot your machine." echo "Upgrade complete. Please reboot your machine."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment