Prevent initializing/synchronizing if container is restarted and not deleted, see #14

This commit is contained in:
flow.gunso
2020-03-10 14:13:39 +01:00
parent 4b0af17cec
commit 8d46c1de76
2 changed files with 27 additions and 20 deletions

View File

@@ -16,16 +16,22 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# Safely initialise the Seafile client. # Initialise the Seafile client, if not already initialised.
seafile_ini=~/.ccnet/seafile.ini seafile_ini="$HOME/.ccnet/seafile.ini"
/usr/bin/seaf-cli init -d ~/.seafile if [ ! -f "$seafile_ini" ]; then
while [ ! -f $seafile_ini ]; do sleep 1; done echo "Initializing Seafile client..."
seaf-cli init -d ~/.seafile
while [ ! -f "$seafile_ini" ]; do sleep 1; done
fi
# Safely start the Seafile daemon. # Start the Seafile daemon.
seafile_sock=~/.seafile/seafile-data/seafile.sock echo "Starting Seafile client..."
/usr/bin/seaf-cli start seaf-cli start
while [ ! -S $seafile_sock ]; do sleep 1; done while [ ! -S "$HOME/.seafile/seafile-data/seafile.sock" ]; do sleep 1; done
# Synchronize the library, if not already synchronized.
if [ -z "$(seaf-cli status | grep -v ^\#)" ]; then
echo "Synchronizing Seafile library..."
# Set the disable_verify_certificate key to true only if the environment variable exists. # Set the disable_verify_certificate key to true only if the environment variable exists.
[[ "$SEAF_SKIP_SSL_CERT" ]] && seaf-cli config -k disable_verify_certificate -v true [[ "$SEAF_SKIP_SSL_CERT" ]] && seaf-cli config -k disable_verify_certificate -v true
@@ -40,6 +46,7 @@ cmd="seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $S
# Run it. # Run it.
if ! eval $cmd; then echo "Failed to synchronize."; exit 1; fi if ! eval $cmd; then echo "Failed to synchronize."; exit 1; fi
fi
# Continously print the log, infinitely. # Continously print the log, infinitely.
while true; do while true; do

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
failures=() failures=()
binaries=(seaf-cli oathtool) binaries=(seaf-cli oathtool grep)
for binary in "${binaries[@]}"; do for binary in "${binaries[@]}"; do
if ! [ -x "$(command -v $binary)" ]; then if ! [ -x "$(command -v $binary)" ]; then