diff --git a/.gitignore b/.gitignore index 11238ed..81799a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .env .idea/ +__pycache__/ .python-version docker-compose.yml diff --git a/LICENSE b/LICENSE index ddba5c4..35990e5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License Copyright (c) 2018 Robin Grönberg +Copyright (c) 2019 Maks Snegov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 2b924a3..c86ac8d 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,3 @@ services: - `DATA_DIR=` The path where to put the files - `SEAFILE_UID=` Downloaded files will have this uid - `SEAFILE_GID=` Downloaded files will have this gid - -## How to find library id: - - diff --git a/imgs/help.png b/imgs/help.png deleted file mode 100644 index 53729f6..0000000 Binary files a/imgs/help.png and /dev/null differ diff --git a/start.sh b/start.sh deleted file mode 100644 index 4e8b435..0000000 --- a/start.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - -set -e -set -u -set -o pipefail -set -x - -DATA_DIR="${DATA_DIR:-/data}" -SEAFILE_UID="${SEAFILE_UID:-1000}" -SEAFILE_GID="${SEAFILE_GID:-1000}" - -get () { - NAME="$1" - JSON="$2" - # Tries to regex setting name from config. Only works with strings for now - VALUE=$(echo $JSON | grep -Po '"'"$NAME"'"\s*:\s*.*?[^\\]"+,*' | sed -n -e 's/.*: *"\(.*\)",*/\1/p') - # Use eval to ensure that nested expressens are executed (config points to environment var) - eval echo $VALUE -} - -setup_lib_sync(){ - if [ ! -d $DATA_DIR ]; then - echo "Using new data directory: $DATA_DIR" - mkdir -p $DATA_DIR - chown seafile:seafile -R $DATA_DIR - fi - TOKEN_JSON=$(curl -d "username=$USERNAME" -d "password=$PASSWORD" ${SERVER_URL}:${SERVER_PORT}/api2/auth-token/ 2> /dev/null) - TOKEN=$(get token "$TOKEN_JSON") - LIBS_IN_SYNC=$(su - seafile -c 'seaf-cli list') - LIBS=(${LIBRARY_ID//:/ }) - for i in "${!LIBS[@]}" - do - LIB="${LIBS[i]}" - LIB_JSON=$(curl -G -H "Authorization: Token $TOKEN" -H 'Accept: application/json; indent=4' ${SERVER_URL}:${SERVER_PORT}/api2/repos/${LIB}/ 2> /dev/null) - LIB_NAME=$(get name "$LIB_JSON") - LIB_NAME_NO_SPACE=${LIB_NAME// /_} - LIB_DIR=${DATA_DIR}/${LIB_NAME_NO_SPACE} - set +e - LIB_IN_SYNC=$(echo "$LIBS_IN_SYNC" | grep "$LIB") - set -e - if [ ${#LIB_IN_SYNC} -eq 0 ]; then - echo "Syncing $LIB_NAME" - mkdir -p $LIB_DIR - chown seafile:seafile -R $LIB_DIR - su - seafile -c "seaf-cli sync -l \"$LIB\" -s \"${SERVER_URL}:${SERVER_PORT}\" -d \"$LIB_DIR\" -u \"$USERNAME\" -p \"$PASSWORD\"" - fi - done -} - -setup_uid(){ - # Setup user/group ids - if [ ! "$(id -u seafile)" -eq "${SEAFILE_UID}" ]; then - # Change the SEAFILE_UID - usermod -o -u "${SEAFILE_UID}" -g "${SEAFILE_GID}" seafile - fi -} - -keep_in_foreground() { - while true; do - tail -f /seafile-client/.ccnet/logs/seafile.log - done -} - -setup_uid -su - seafile -c "seaf-cli start" -sleep 10 -setup_lib_sync -keep_in_foreground