diff --git a/scripts/_common.sh b/scripts/_common.sh index 3e8cc87..2106b79 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,7 +6,7 @@ readonly time_zone="$(cat /etc/timezone)" readonly python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)" # Create special path with / at the end -if [[ $path == '/' ]] +if [[ "$path" == '/' ]] then readonly path2="$path" else @@ -33,20 +33,20 @@ install_pkg_conf() { install_dependance() { # Clean venv is it was on python3 with old version in case major upgrade of debian - if [ ! -e $install_dir/venv/bin/python3 ] || [ ! -e $install_dir/venv/lib/python$python_version ]; then - ynh_secure_remove --file=$install_dir/venv/bin - ynh_secure_remove --file=$install_dir/venv/lib - ynh_secure_remove --file=$install_dir/venv/lib64 - ynh_secure_remove --file=$install_dir/venv/include - ynh_secure_remove --file=$install_dir/venv/share - ynh_secure_remove --file=$install_dir/venv/pyvenv.cfg + if [ ! -e "$install_dir"/venv/bin/python3 ] || [ ! -e "$install_dir/venv/lib/python$python_version" ]; then + ynh_secure_remove --file="$install_dir"/venv/bin + ynh_secure_remove --file="$install_dir"/venv/lib + ynh_secure_remove --file="$install_dir"/venv/lib64 + ynh_secure_remove --file="$install_dir"/venv/include + ynh_secure_remove --file="$install_dir"/venv/share + ynh_secure_remove --file="$install_dir"/venv/pyvenv.cfg fi # Create venv if it don't exist - test -e $install_dir/venv/bin/python3 || python3 -m venv $install_dir/venv + test -e "$install_dir"/venv/bin/python3 || python3 -m venv "$install_dir"/venv py_dependancy="django==4.2.* future==0.18.* mysqlclient==2.1.* pymysql pillow==10.2.* pylibmc captcha==0.5.* markupsafe==2.0.1 jinja2 sqlalchemy==2.0.18 psd-tools django-pylibmc django_simple_captcha==0.6.* djangosaml2==1.5.* pysaml2==7.2.* pycryptodome==3.16.* cffi==1.15.1 lxml python-ldap==3.4.3" - $install_dir/venv/bin/pip3 install --upgrade --timeout=3600 $py_dependancy + "$install_dir"/venv/bin/pip3 install --upgrade --timeout=3600 $py_dependancy # Create symbolic link to venv package on seahub ls "$install_dir/venv/lib/python$python_version/site-packages" | while read -r f; do @@ -69,10 +69,10 @@ set_permission() { setfacl -m user:www-data:rX "$install_dir" setfacl -m user:www-data:rX "$install_dir/seafile-server-$seafile_version" # At install time theses directory are not available - test -e $install_dir/seafile-server-$seafile_version/seahub && setfacl -m user:www-data:rX $install_dir/seafile-server-$seafile_version/seahub - test -e $install_dir/seafile-server-$seafile_version/seahub/media && setfacl -R -m user:www-data:rX $install_dir/seafile-server-$seafile_version/seahub/media - test -e $install_dir/seahub-data && setfacl -m user:www-data:rX $data_dir - test -e $install_dir/seahub-data && setfacl -R -m user:www-data:rX $data_dir/seahub-data + test -e "$install_dir/seafile-server-$seafile_version/seahub" && setfacl -m user:www-data:rX "$install_dir/seafile-server-$seafile_version/seahub" + test -e "$install_dir/seafile-server-$seafile_version/seahub/media" && setfacl -R -m user:www-data:rX "$install_dir/seafile-server-$seafile_version/seahub/media" + test -e "$install_dir"/seahub-data && setfacl -m user:www-data:rX "$data_dir" + test -e "$install_dir"/seahub-data && setfacl -R -m user:www-data:rX "$data_dir"/seahub-data find "$data_dir" \( \! -perm -o= \ -o \! -user "$app" \ diff --git a/scripts/change_url b/scripts/change_url index febbf5e..545ed6d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -11,14 +11,14 @@ source ./_common.sh # Source YunoHost helpers source /usr/share/yunohost/helpers -seafile_version=$(ynh_app_upstream_version) +seafile_version="$(ynh_app_upstream_version)" # Create special path with / at the end if [[ $path == '/' ]] then - path2=$path + path2="$path" else - path2=$path"/" + path2="$path/" fi #================================================= @@ -46,14 +46,14 @@ pkill -f seahub || true ynh_script_progression --message="Updating seafile configuration..." # Update Seafile Config -ynh_add_config --template=seahub_settings.py --destination=$install_dir/conf/seahub_settings.py -ynh_add_config --template=ccnet.conf --destination=$install_dir/conf/ccnet.conf -ynh_add_config --template=gunicorn.conf.py --destination=$install_dir/conf/gunicorn.conf.py -ynh_add_config --template=seafdav.conf --destination=$install_dir/conf/seafdav.conf +ynh_add_config --template=seahub_settings.py --destination="$install_dir"/conf/seahub_settings.py +ynh_add_config --template=ccnet.conf --destination="$install_dir"/conf/ccnet.conf +ynh_add_config --template=gunicorn.conf.py --destination="$install_dir"/conf/gunicorn.conf.py +ynh_add_config --template=seafdav.conf --destination="$install_dir"/conf/seafdav.conf # Update permissions -ynh_permission_url --permission=file_server --url=$domain/seafhttp -ynh_permission_url --permission=webdav --url=$domain/seafdav +ynh_permission_url --permission=file_server --url="$domain"/seafhttp +ynh_permission_url --permission=webdav --url="$domain"/seafdav # Clean url in config in DB clean_url_in_db_config diff --git a/scripts/install b/scripts/install index 3a23c56..ad3425f 100644 --- a/scripts/install +++ b/scripts/install @@ -103,7 +103,7 @@ ln -s "$data_dir"/seahub-data "$install_dir"/seahub-data ln -s /var/log/"$app" "$install_dir"/logs # Fix local warning -ynh_replace_string --match_string=en_US.UTF-8 --replace_string=${LANG:-'en_US.UTF-8'} --target_file="$install_dir/seafile-server-$seafile_version/seahub.sh" +ynh_replace_string --match_string=en_US.UTF-8 --replace_string="${LANG:-'en_US.UTF-8'}" --target_file="$install_dir/seafile-server-$seafile_version/seahub.sh" # Add Seafile Server to startup ynh_script_progression --message="Configuring a systemd service..." diff --git a/scripts/remove b/scripts/remove index 8da5613..3614395 100644 --- a/scripts/remove +++ b/scripts/remove @@ -11,7 +11,7 @@ source ./_common.sh # Source YunoHost helpers source /usr/share/yunohost/helpers -seafile_version=$(ynh_app_upstream_version) +seafile_version="$(ynh_app_upstream_version)" #================================================= # STANDARD REMOVE @@ -34,8 +34,8 @@ if [ "$YNH_APP_PURGE" -eq 1 ]; then ynh_secure_remove --file=/var/log/"$app" fi ynh_script_progression --message="Removing code..." -ynh_secure_remove --file=/var/www/$app -ynh_secure_remove --file=/opt/yunohost/$app +ynh_secure_remove --file=/var/www/"$app" +ynh_secure_remove --file=/opt/yunohost/"$app" # Remove databases ynh_script_progression --message="Removing databases..." diff --git a/scripts/restore b/scripts/restore index 0d03a58..830de29 100644 --- a/scripts/restore +++ b/scripts/restore @@ -11,13 +11,10 @@ source ../settings/scripts/_common.sh # Source YunoHost helpers source /usr/share/yunohost/helpers -seafile_version=$(ynh_app_upstream_version) +seafile_version="$(ynh_app_upstream_version)" ynh_script_progression --message="Loading settings..." -# Retrieve arguments -seafile_version=$(ynh_app_upstream_version) - #================================================= # STANDARD RESTORATION STEPS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 0df166d..fd2b9bd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,8 +11,8 @@ source ./_common.sh # Source YunoHost helpers source /usr/share/yunohost/helpers -seafile_version=$(ynh_app_upstream_version) -installed_version=${YNH_APP_CURRENT_VERSION/~ynh*/} +seafile_version="$(ynh_app_upstream_version)" +installed_version="${YNH_APP_CURRENT_VERSION/~ynh*/}" ensure_vars_set @@ -47,7 +47,7 @@ fi # Set missing settings if [ -z "${seahub_secret_key:-}" ]; then - seahub_secret_key=$(grep -P 'SECRET_KEY\s*=\s*".+"' "$install_dir"/conf/seahub_settings.py | cut -d'"' -f2) + seahub_secret_key="$(grep -P 'SECRET_KEY\s*=\s*".+"' "$install_dir"/conf/seahub_settings.py | cut -d'"' -f2)" ynh_app_setting_set --app="$app" --key=seahub_secret_key --value="$seahub_secret_key" fi @@ -113,7 +113,7 @@ ynh_script_progression --message="Configuring application..." set_permission # do the upgrade ( the ";&" syntax mean when it go in the first case which is true it do all the next case) -case $installed_version in +case "$installed_version" in "4."* ) # Update seafile by script ynh_die "Upgrade form the version 4.x was removed. Upgrade from this version won't be supported any more." @@ -168,11 +168,11 @@ sudo -u "$app" bash "$install_dir/seafile-server-$seafile_version/upgrade/minor- clean_url_in_db_config # Update seafile config files -ynh_add_jinja_config --template=seahub_settings.py --destination=$install_dir/conf/seahub_settings.py -ynh_add_config --template=seafile.conf --destination=$install_dir/conf/seafile.conf -ynh_add_config --template=ccnet.conf --destination=$install_dir/conf/ccnet.conf -ynh_add_config --template=gunicorn.conf.py --destination=$install_dir/conf/gunicorn.conf.py -ynh_add_config --template=seafdav.conf --destination=$install_dir/conf/seafdav.conf +ynh_add_jinja_config --template=seahub_settings.py --destination="$install_dir"/conf/seahub_settings.py +ynh_add_config --template=seafile.conf --destination="$install_dir"/conf/seafile.conf +ynh_add_config --template=ccnet.conf --destination="$install_dir"/conf/ccnet.conf +ynh_add_config --template=gunicorn.conf.py --destination="$install_dir"/conf/gunicorn.conf.py +ynh_add_config --template=seafdav.conf --destination="$install_dir"/conf/seafdav.conf ynh_add_config --template=seafevents.conf --destination="$install_dir"/conf/seafevents.conf # Fix local warning @@ -223,10 +223,10 @@ sleep 2 # remove old version files ynh_script_progression --message="Cleaning system and updating settings..." -ls "$install_dir" | grep "seafile-server-" | grep -E -v "(${seafile_version//./\\.})|(latest)" | \ -while read -r f -do - ynh_secure_remove --file="$install_dir/$f" +for f in "$install_dir"/seafile-server-*;do + if [[ ! "$f" =~ ${seafile_version//./\\.}|latest ]]; then + ynh_secure_remove --file="$f" + fi done ynh_script_progression --message="Upgrade of $app completed" --last