WEB_ONLY=""
REBUILD=""
BUILD_XUL=""
+RESTART_ONLY=""
# if the script exits early, SUCCESS will be left as 0,
# which is our sign to warn the user.
$0 -d -w -p
Options:
+
+ -o
+ Restart Evergreen/Apache services only. No code is
+ updated or installed.
-p
'git pull' the currently checked out branch.
Build a XUL client and place it in the published "builds"
directory.
+ -f
+ Service startup sleep time in seconds. Defaults to
+ $START_SLEEP. Increase this value if autogen regularly
+ fails.
+
USAGE
trap - EXIT
exit;
}
+function recover_opensrf_file_ownership {
+ # opensrf always owns /openils, but /openils has NFS shares in
+ # multi-box environments. Using find + chown to skip NFS dirs still
+ # turns out to be a slow process, since it results in a lot of
+ # individual file chowns instead of recursive chowns.
+ # This approach ensures all non-NFS shares are modified and runs quickly.
+ set +e # chown returns non-zero on various failures we can ignore
+
+ fstype=$(stat --file-system -c %T /openils/var/data/offline)
+
+ if [ "$fstype" != "nfs" ]; then
+ # if the offline directory is not an NFS share, assume this
+ # server has no NFS shares under /openils.
+ announce "Assuming no NFS shares present"
+ sudo chown -R opensrf:opensf /openils 2> /dev/null
+ return
+ fi
+
+ # otherwise recursively chown where possible, safely avoid
+ # the typical /openils NFS shares.
+
+ announce "Navigating NFS shares"
+
+ for dir in /openils/*; do
+ if [ $(basename $dir) != 'var' ]; then
+ sudo chown -R opensrf:opensrf $dir 2> /dev/null
+ fi
+ done
+
+ for dir in /openils/var/*; do
+ if [ $(basename $dir) != "web" \
+ -a $(basename $dir) != "data" ]; then
+ sudo chown -R opensrf:opensrf $dir 2> /dev/null
+ fi
+ done
+
+ # /openils/var/data/vandelay is staging only
+ for dir in /openils/var/data/*; do
+ if [ $(basename $dir) != "offline" \
+ -a $(basename $dir) != "vandelay" ]; then
+ sudo chown -R opensrf:opensrf $dir 2> /dev/null
+ fi
+ done
+
+ for dir in /openils/var/web/*; do
+ if [ $(basename $dir) != "reporter" ]; then
+ sudo chown -R opensrf:opensrf $dir 2> /dev/null
+ fi
+ done
+ set -e
+}
+
+
function deploy_code {
announce "Building and installing Evergreen"
# recover ownership of repo files after sudo/install
sudo chown -R $OWNER:$OWNER $EVERGREEN_BASE
- announce "Running post-install steps"
+ announce "Chowning /openils"
- # opensrf always owns /openils
- set +e # chown returns non-zero on R/O NFS shares
- sudo chown -R opensrf:opensrf /openils > /dev/null 2>&1;
- set -e
+ recover_opensrf_file_ownership
+
+ announce "Publishing staff client build"
publish_staff_client_build;
copy_custom_files;
+}
+
+function start_services {
+ announce "Starting services"
if [ -n "$OSRF" ]; then
# give services a chance to start up
announce "Giving services $START_SLEEP seconds to start up"
sleep $START_SLEEP;
-
- announce "Running autogen"
- $OSRF /openils/bin/autogen.sh > /dev/null
}
# -- script starts here --
trap on_exit EXIT;
-while getopts "t:b:r:s:i:pdanwchx" opt; do
+while getopts "t:b:r:s:i:f:pdanwchxo" opt; do
case $opt in
t) GIT_TAG="$OPTARG";;
b) GIT_BRANCH="$OPTARG";;
r) GIT_REMOTE="$OPTARG";;
s) CLIENT_BUILD_ID="$OPTARG";;
i) CLIENT_SERIES_ID="$OPTARG";;
+ f) START_SLEEP="$OPTARG";;
p) GIT_PULL="YES";;
d) SKIP_DETACH="YES";;
a) REATTACH="YES";;
w) WEB_ONLY="YES";;
c) REBUILD="YES";;
x) BUILD_XUL="YES";;
+ o) RESTART_ONLY="YES";;
h|*) usage;
esac
done;
set_builder;
-inspect_params;
+if [ -z "$RESTART_ONLY" ]; then
+ # restart trumps all other commands.
+ inspect_params;
+fi
if [ -z "$SKIP_DETACH" ]; then
deploy_web
else
+ if [ -z "$SKIP_APACHE" ]; then
+ announce "Stopping Apache"
+ sudo service apache2 stop > /dev/null
+ fi
+
# Note the use of --fast-shutdown-all, which is faster than the
# default graceful shutdown. We don't need graceful shutdown,
# since we will not be stopping potentially active services.
$OSRF /openils/bin/osrf_control --localhost \
--fast-shutdown-all > /dev/null
- if [ -z "$SKIP_APACHE" ]; then
- announce "Stopping Apache"
- sudo service apache2 stop > /dev/null
- fi
+ if [ -n "$RESTART_ONLY" ]; then
+ sleep 1;
+ start_services;
+
+ else
+ fetch_code;
+ deploy_code;
+ start_services;
- fetch_code;
- deploy_code;
+ announce "Running autogen"
+ $OSRF /openils/bin/autogen.sh > /dev/null
+ fi
if [ -z "$SKIP_APACHE" ]; then
announce "Starting Apache"