mirror of
https://github.com/YunoHost-Apps/weblate_ynh.git
synced 2024-10-01 13:35:04 +02:00
Code cleanup
This commit is contained in:
parent
ba26794dd0
commit
639f95aa63
7 changed files with 28 additions and 37 deletions
|
@ -10,7 +10,7 @@ ynh_psql_test_if_first_run() {
|
||||||
systemctl start postgresql
|
systemctl start postgresql
|
||||||
su --command="psql -c\"ALTER user postgres WITH PASSWORD '${pgsql}'\"" postgres
|
su --command="psql -c\"ALTER user postgres WITH PASSWORD '${pgsql}'\"" postgres
|
||||||
# we can't use peer since YunoHost create users with nologin
|
# we can't use peer since YunoHost create users with nologin
|
||||||
sed -i '/local\s*all\s*all\s*peer/i \
|
sed -i '/local\s*all\s*all\s*peer/i
|
||||||
local all all password' /etc/postgresql/9.4/main/pg_hba.conf
|
local all all password' /etc/postgresql/9.4/main/pg_hba.conf
|
||||||
systemctl enable postgresql
|
systemctl enable postgresql
|
||||||
systemctl reload postgresql
|
systemctl reload postgresql
|
||||||
|
@ -51,7 +51,7 @@ ynh_psql_execute_as_root () {
|
||||||
ynh_psql_execute_file_as_root() {
|
ynh_psql_execute_file_as_root() {
|
||||||
file="$1"
|
file="$1"
|
||||||
db="$2"
|
db="$2"
|
||||||
su -c "psql $db" postgres < $file
|
su -c "psql $db" postgres < "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a database, an user and its password. Then store the password in the app's config
|
# Create a database, an user and its password. Then store the password in the app's config
|
||||||
|
|
|
@ -27,10 +27,9 @@ source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||||
db_pwd=$(ynh_app_setting_get $app pgsqlpwd)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD BACKUP STEPS
|
# STANDARD BACKUP STEPS
|
||||||
|
|
|
@ -107,7 +107,6 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Hub needs a home directory with a config file
|
# Hub needs a home directory with a config file
|
||||||
smtp_pwd=$(ynh_string_random)
|
|
||||||
ynh_system_user_create "$app" "$final_path"
|
ynh_system_user_create "$app" "$final_path"
|
||||||
# Allow bash for our user, so he can use Hub
|
# Allow bash for our user, so he can use Hub
|
||||||
chsh --shell /bin/bash "$app"
|
chsh --shell /bin/bash "$app"
|
||||||
|
@ -139,7 +138,7 @@ case "$arch" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[[ $(sha256sum "$file_bin" | cut -d' ' -f1) = $sha256sum ]] || ynh_die "Hub's sha256sum failed (arch: ${arch})"
|
[[ $(sha256sum "$file_bin" | cut -d' ' -f1) = "$sha256sum" ]] || ynh_die "Hub's sha256sum failed (arch: ${arch})"
|
||||||
|
|
||||||
tar --extract --file "$file_bin" "$version/bin/hub"
|
tar --extract --file "$file_bin" "$version/bin/hub"
|
||||||
mkdir "$final_path/bin/"
|
mkdir "$final_path/bin/"
|
||||||
|
@ -207,7 +206,6 @@ ynh_replace_string "__DOMAIN__" "$domain" "$final_path/venv/lib/python2.7
|
||||||
ynh_replace_string "__KEY__" "$key" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
ynh_replace_string "__KEY__" "$key" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||||
ynh_replace_string "__PATHURL__" "$path_url" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
ynh_replace_string "__PATHURL__" "$path_url" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||||
ynh_replace_string "__SMTPPWD__" "$smtp_pwd" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
|
||||||
ynh_replace_string "__MEMCPORT__" "$memc_port" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
ynh_replace_string "__MEMCPORT__" "$memc_port" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||||
ynh_replace_string "__GITHUBUSER__" "$github_account" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
ynh_replace_string "__GITHUBUSER__" "$github_account" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||||
|
|
||||||
|
@ -233,7 +231,7 @@ ynh_replace_string "__GITHUBUSER__" "$github_account" "$final_path/venv/lib/pyth
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP CRON
|
# SETUP CRON
|
||||||
#=================================================
|
#=================================================
|
||||||
cp ../conf/cron_weblate "/etc/cron.d/$app"
|
cp ../conf/cron "/etc/cron.d/$app"
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app"
|
ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
set -eu
|
set -u
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -15,9 +15,7 @@ source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||||
port=$(ynh_app_setting_get $app port)
|
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SERVICE FROM ADMIN PANEL
|
# REMOVE SERVICE FROM ADMIN PANEL
|
||||||
|
@ -87,4 +85,4 @@ ynh_secure_remove "/etc/systemd/system/$app.service"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete $app
|
ynh_system_user_delete "$app"
|
||||||
|
|
|
@ -27,12 +27,11 @@ source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path_url=$(ynh_app_setting_get $app path)
|
path_url=$(ynh_app_setting_get "$app" path)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||||
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
||||||
smtp_pwd=$(ynh_app_setting_get $app smtppwd)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
|
|
@ -15,30 +15,27 @@ source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
path_url=$(ynh_app_setting_get "$app" path)
|
||||||
path_url=$(ynh_app_setting_get $app path)
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
admin=$(ynh_app_setting_get $app admin)
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
port=$(ynh_app_setting_get $app port)
|
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
|
||||||
smtp_pwd=$(ynh_app_setting_get $app smtppwd)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$is_public" = "Yes" ]; then
|
if [ "$is_public" = "Yes" ]; then
|
||||||
ynh_app_setting_set $app is_public 1 # Fix is_public as a boolean value
|
ynh_app_setting_set "$app" is_public 1 # Fix is_public as a boolean value
|
||||||
is_public=1
|
is_public=1
|
||||||
elif [ "$is_public" = "No" ]; then
|
elif [ "$is_public" = "No" ]; then
|
||||||
ynh_app_setting_set $app is_public 0
|
ynh_app_setting_set "$app" is_public 0
|
||||||
is_public=0
|
is_public=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $db_name ]; then # If db_name doesn't exist, create it
|
if [ -z "$db_name" ]; then # If db_name doesn't exist, create it
|
||||||
db_name=$(ynh_sanitize_dbid $app)
|
db_name=$(ynh_sanitize_dbid "$app")
|
||||||
ynh_app_setting_set $app db_name $db_name
|
ynh_app_setting_set "$app" db_name "$db_name"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -46,7 +43,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Normalize the URL path syntax
|
# Normalize the URL path syntax
|
||||||
path_url=$(ynh_normalize_url_path $path_url)
|
path_url=$(ynh_normalize_url_path "$path_url")
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
@ -92,7 +89,7 @@ chsh --shell /bin/bash "$app"
|
||||||
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"
|
||||||
cd ${final_path}
|
cd "${final_path}"
|
||||||
weblate migrate --noinput
|
weblate migrate --noinput
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -118,13 +115,13 @@ ynh_use_logrotate
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]
|
if [ $is_public -eq 0 ]
|
||||||
then # Remove the public access
|
then # Remove the public access
|
||||||
ynh_app_setting_delete $app skipped_uris
|
ynh_app_setting_delete "$app" skipped_uris
|
||||||
fi
|
fi
|
||||||
# Make app public if necessary
|
# Make app public if necessary
|
||||||
if [ $is_public -eq 1 ]
|
if [ $is_public -eq 1 ]
|
||||||
then
|
then
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway
|
# unprotected_uris allows SSO credentials to be passed anyway
|
||||||
ynh_app_setting_set $app unprotected_uris "/"
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue