shimunn 4ebc0bdf82
Some checks are pending
continuous-integration/drone/push Build is failing
[CI SKIP] proper init
2019-04-19 18:52:36 +02:00

43 lines
1.1 KiB
Bash

#!/bin/bash
LATEST=$SEAF/seafile-server-latest
function ext_url {
echo "${SEAF_URL:-http://$(hostname)}/seafhttp"
}
function patch_seahub_conf {
KEY="FILE_SERVER_ROOT"
ENTRY="$KEY = '$(ext_url)'"
CONF="$SEAF/conf/seahub_settings.py"
grep "$KEY" -i "$CONF"
if [ $? -eq 1 ]; then
echo "Patched seahub_settings.py: set $ENTRY"
echo -e "\n$ENTRY" >> "$CONF"
fi
}
function last_update {
if [ -e "$LATEST/install_date" ]; then
date -d $(cat "$LATEST/install_date") "+%s"
else
echo 0
fi
}
### Setup ###
if [ ! -e "$LATEST" ]; then
(>&2 echo This appears to be the fist run, installing..)
mkdir -p $SEAF/conf
cp /etc/seafile/* $SEAF/conf/* -rf
/usr/local/sbin/upgrade main
exit $?
else
LAST_UPGRADE=$(last_update)
SINCE_UPGRADE=$(((($(date "+%s") - $LAST_UPGRADE))/(60*60*24)))
if [ $LAST_UPGRADE -gt 0 ] && [ "0$SEAF_UPGRADE_INTERVAL" -gt 0 ] && [ $SINCE_UPGRADE -gt "0$SEAF_UPGRADE_INTERVAL" ]; then
echo "It's been $SINCE_UPGRADE days since the last Upgrade\nPERFORMING UPGRADE NOW\nSet SEAF_UPGRADE_INTERVAL=0 disable automatic updates"
/usr/local/sbin/upgrade main
fi
patch_seahub_conf
fi