1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/weblate_ynh.git synced 2024-10-01 13:35:04 +02:00

fix scripts

This commit is contained in:
Kay0u 2020-10-28 16:10:55 +01:00
parent d43693f8e8
commit 33182706ed
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D
4 changed files with 42 additions and 38 deletions

View file

@ -106,16 +106,17 @@ fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
# MODIFY settings.py # MODIFY SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Modify weblate's config file..." --time --weight=1 ynh_script_progression --message="Modify weblate's config file..." --time --weight=1
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
ynh_backup_if_checksum_is_different --file="$settings"
# Change the path in the nginx config file # Change the path in the nginx config file
if [ $change_path -eq 1 ] if [ $change_path -eq 1 ]
then then
ynh_replace_string --match_string="URL_PREFIX = '${old_path%/}'" --replace_string="URL_PREFIX = '${new_path%/}'" --target_file="$settings" ynh_replace_string --match_string="URL_PREFIX = \"${old_path%/}\"" --replace_string="URL_PREFIX = \"${new_path%/}\"" --target_file="$settings"
fi fi
# Change the domain for nginx # Change the domain for nginx
@ -124,11 +125,26 @@ then
# replace SERVER_EMAIL # replace SERVER_EMAIL
ynh_replace_string --match_string="noreply@$old_domain" --replace_string="noreply@$new_domain" --target_file="$settings" ynh_replace_string --match_string="noreply@$old_domain" --replace_string="noreply@$new_domain" --target_file="$settings"
# replace ALLOWED_HOSTS # replace ALLOWED_HOSTS
ynh_replace_string --match_string="['$old_domain']" --replace_string="['$new_domain']" --target_file="$settings" ynh_replace_string --match_string="ALLOWED_HOSTS = \[\"$old_domain\"\]" --replace_string="ALLOWED_HOSTS = \[\"$new_domain\"\]" --target_file="$settings"
fi fi
ynh_store_file_checksum --file="$settings" ynh_store_file_checksum --file="$settings"
#=================================================
# MODIFY UWSGI
#=================================================
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
ynh_backup_if_checksum_is_different --file="$finaluwsgiini"
# Change the path in the nginx config file
if [ $change_path -eq 1 ]
then
ynh_replace_string --match_string="mount = $old_path=" --replace_string="mount = $new_path=" --target_file="$finaluwsgiini"
fi
ynh_store_file_checksum --file="$finaluwsgiini"
#================================================= #=================================================
# ChangeSite inside weblate # ChangeSite inside weblate
#================================================= #=================================================
@ -137,7 +153,7 @@ ynh_script_progression --message="Run weblate's command changesite..." --time --
set +eu set +eu
source "${final_path}/venv/bin/activate" source "${final_path}/venv/bin/activate"
export DJANGO_SETTINGS_MODULE="weblate.settings" export DJANGO_SETTINGS_MODULE="weblate.settings"
weblate changesite --set-name "$new_domain" sudo -u $app $final_path/venv/bin/weblate changesite --set-name "$new_domain"
) )
#================================================= #=================================================

View file

@ -121,14 +121,14 @@ virtualenv --python=python3 "${final_path}/venv"
set +o nounset set +o nounset
source "${final_path}/venv/bin/activate" source "${final_path}/venv/bin/activate"
set -o nounset set -o nounset
pip install --upgrade pip setuptools wheel sudo -u $app $final_path/venv/bin/pip install --upgrade pip setuptools wheel
# Still needed with latest version of weblate? # Still needed with latest version of weblate?
pip install celery==4.* sudo -u $app $final_path/venv/bin/pip install celery==4.*
pip install Weblate=="$current_version" sudo -u $app $final_path/venv/bin/pip install Weblate=="$current_version"
pip install psycopg2-binary ruamel.yaml aeidon phply sudo -u $app $final_path/venv/bin/pip install psycopg2-binary ruamel.yaml aeidon phply
#pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml #pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml
# specific to YunoHost package: # specific to YunoHost package:
pip install django_sendmail_backend sudo -u $app $final_path/venv/bin/pip install django_sendmail_backend
) )
#================================================= #=================================================
@ -174,11 +174,11 @@ ynh_script_progression --message="Filling up the database..." --time --weight=1
set -o nounset set -o nounset
export DJANGO_SETTINGS_MODULE="weblate.settings" export DJANGO_SETTINGS_MODULE="weblate.settings"
# the user needs to be weblate for postgresql # the user needs to be weblate for postgresql
weblate migrate --noinput sudo -u $app $final_path/venv/bin/weblate migrate --noinput
# generate static files # generate static files
weblate collectstatic --noinput sudo -u $app $final_path/venv/bin/weblate collectstatic --noinput
weblate changesite --set-name "$domain" sudo -u $app $final_path/venv/bin/weblate changesite --set-name "$domain"
weblate createadmin --no-color \ sudo -u $app $final_path/venv/bin/weblate createadmin --no-color \
--password "weblate" \ --password "weblate" \
--username "$admin" \ --username "$admin" \
--email "$admin_mail" --email "$admin_mail"
@ -234,15 +234,11 @@ ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.servic
#================================================= #=================================================
# Set permissions to app files # Set permissions to app files
chown -R root:root "$final_path" chown -R "$app": "$final_path"
chown -R "$app": "$final_path/data"
mkdir -p "$final_path/avatar-cache" mkdir -p "$final_path/avatar-cache"
chown -R "$app": "$final_path/avatar-cache" chown -R "$app": "$final_path/avatar-cache"
mkdir -p "/var/run/$app"
chown -R "$app": "/var/run/$app"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================

View file

@ -67,15 +67,11 @@ ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell
#================================================= #=================================================
# Restore permissions on app files # Restore permissions on app files
chown -R root:root "$final_path" chown -R "$app": "$final_path"
chown -R "$app": "$final_path/data"
mkdir -p "$final_path/avatar-cache" mkdir -p "$final_path/avatar-cache"
chown -R "$app": "$final_path/avatar-cache" chown -R "$app": "$final_path/avatar-cache"
mkdir -p "/var/run/$app"
chown -R "$app": "/var/run/$app"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================

View file

@ -159,14 +159,14 @@ virtualenv --python=python3 "${final_path}/venv"
set +o nounset set +o nounset
source "${final_path}/venv/bin/activate" source "${final_path}/venv/bin/activate"
set -o nounset set -o nounset
pip install --upgrade pip setuptools wheel sudo -u $app $final_path/venv/bin/pip install --upgrade pip setuptools wheel
# Still needed with latest version of weblate? # Still needed with latest version of weblate?
pip install celery==4.* sudo -u $app $final_path/venv/bin/pip install celery==4.*
pip install --upgrade Weblate=="$current_version" sudo -u $app $final_path/venv/bin/pip install --upgrade Weblate=="$current_version"
pip install psycopg2-binary ruamel.yaml aeidon phply sudo -u $app $final_path/venv/bin/pip install psycopg2-binary ruamel.yaml aeidon phply
#pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml #pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml
# specific to YunoHost package: # specific to YunoHost package:
pip install django_sendmail_backend sudo -u $app $final_path/venv/bin/pip install django_sendmail_backend
) )
#================================================= #=================================================
@ -212,11 +212,11 @@ ynh_systemd_action --service_name="$app-celery" --action="start"
export DJANGO_SETTINGS_MODULE="weblate.settings" export DJANGO_SETTINGS_MODULE="weblate.settings"
cd "${final_path}" cd "${final_path}"
weblate migrate --noinput sudo -u $app $final_path/venv/bin/weblate migrate --noinput
weblate collectstatic --noinput sudo -u $app $final_path/venv/bin/weblate collectstatic --noinput
weblate setuplang sudo -u $app $final_path/venv/bin/weblate setuplang
weblate setupgroups sudo -u $app $final_path/venv/bin/weblate setupgroups
weblate compilemessages sudo -u $app $final_path/venv/bin/weblate compilemessages
sudo -u $app $final_path/venv/bin/weblate check --deploy sudo -u $app $final_path/venv/bin/weblate check --deploy
) )
@ -243,15 +243,11 @@ yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log"
#================================================= #=================================================
# Set right permissions for curl installation # Set right permissions for curl installation
chown -R root:root "$final_path" chown -R "$app": "$final_path"
chown -R "$app": "$final_path/data"
mkdir -p "$final_path/avatar-cache" mkdir -p "$final_path/avatar-cache"
chown -R "$app": "$final_path/avatar-cache" chown -R "$app": "$final_path/avatar-cache"
mkdir -p "/var/run/$app"
chown -R "$app": "/var/run/$app"
#================================================= #=================================================
# START SYSTEMD SERVICES # START SYSTEMD SERVICES
#================================================= #=================================================