mirror of
https://github.com/YunoHost-Apps/ffsync_ynh.git
synced 2024-09-03 18:26:38 +02:00
Change order of instruction and fix uwsgi helper
This commit is contained in:
parent
e345831487
commit
87d4333a31
3 changed files with 61 additions and 75 deletions
|
@ -24,16 +24,22 @@ ynh_check_global_uwsgi_config () {
|
||||||
# __PATH__ by $path_url
|
# __PATH__ by $path_url
|
||||||
# __FINALPATH__ by $final_path
|
# __FINALPATH__ by $final_path
|
||||||
#
|
#
|
||||||
|
# And dynamic variables (from the last example) :
|
||||||
|
# __PATH_2__ by $path_2
|
||||||
|
# __PORT_2__ by $port_2
|
||||||
|
#
|
||||||
# usage: ynh_add_uwsgi_service
|
# usage: ynh_add_uwsgi_service
|
||||||
#
|
#
|
||||||
# to interact with your service: `systemctl <action> uwsgi-app@app`
|
# to interact with your service: `systemctl <action> uwsgi-app@app`
|
||||||
ynh_add_uwsgi_service () {
|
ynh_add_uwsgi_service () {
|
||||||
ynh_check_global_uwsgi_config
|
ynh_check_global_uwsgi_config
|
||||||
|
|
||||||
|
local others_var=${1:-}
|
||||||
|
local finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
|
|
||||||
# www-data group is needed since it is this nginx who will start the service
|
# www-data group is needed since it is this nginx who will start the service
|
||||||
usermod --append --groups www-data "$app" || ynh_die "It wasn't possible to add user $app to group www-data"
|
usermod --append --groups www-data "$app" || ynh_die "It wasn't possible to add user $app to group www-data"
|
||||||
|
|
||||||
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
|
||||||
ynh_backup_if_checksum_is_different "$finaluwsgiini"
|
ynh_backup_if_checksum_is_different "$finaluwsgiini"
|
||||||
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
||||||
|
|
||||||
|
@ -48,6 +54,15 @@ ynh_add_uwsgi_service () {
|
||||||
if test -n "${app:-}"; then
|
if test -n "${app:-}"; then
|
||||||
ynh_replace_string "__APP__" "$app" "$finaluwsgiini"
|
ynh_replace_string "__APP__" "$app" "$finaluwsgiini"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Replace all other variable given as arguments
|
||||||
|
for var_to_replace in $others_var
|
||||||
|
do
|
||||||
|
# ${var_to_replace^^} make the content of the variable on upper-cases
|
||||||
|
# ${!var_to_replace} get the content of the variable named $var_to_replace
|
||||||
|
ynh_replace_string "__${var_to_replace^^}__" "${!var_to_replace}" "$finaluwsgiini"
|
||||||
|
done
|
||||||
|
|
||||||
ynh_store_file_checksum "$finaluwsgiini"
|
ynh_store_file_checksum "$finaluwsgiini"
|
||||||
|
|
||||||
chown $app:root "$finaluwsgiini"
|
chown $app:root "$finaluwsgiini"
|
||||||
|
@ -58,8 +73,11 @@ ynh_add_uwsgi_service () {
|
||||||
chmod -R u=rwX,g=rX,o= /var/log/uwsgi/$app
|
chmod -R u=rwX,g=rX,o= /var/log/uwsgi/$app
|
||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
systemctl stop "uwsgi-app@$app.service"
|
||||||
systemctl enable "uwsgi-app@$app.socket"
|
systemctl enable "uwsgi-app@$app.socket"
|
||||||
systemctl start "uwsgi-app@$app.socket"
|
systemctl start "uwsgi-app@$app.socket"
|
||||||
|
systemctl enable "uwsgi-app@$app.service"
|
||||||
|
systemctl start "uwsgi-app@$app.service"
|
||||||
|
|
||||||
# Add as a service
|
# Add as a service
|
||||||
yunohost service add "uwsgi-app@$app" --log "/var/log/uwsgi/$app/$app.log"
|
yunohost service add "uwsgi-app@$app" --log "/var/log/uwsgi/$app/$app.log"
|
||||||
|
@ -69,10 +87,12 @@ ynh_add_uwsgi_service () {
|
||||||
#
|
#
|
||||||
# usage: ynh_remove_uwsgi_service
|
# usage: ynh_remove_uwsgi_service
|
||||||
ynh_remove_uwsgi_service () {
|
ynh_remove_uwsgi_service () {
|
||||||
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
local finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
if [ -e "$finaluwsgiini" ]; then
|
if [ -e "$finaluwsgiini" ]; then
|
||||||
systemctl stop "uwsgi-app@$app.socket"
|
systemctl stop "uwsgi-app@$app.socket"
|
||||||
systemctl disable "uwsgi-app@$app.socket"
|
systemctl disable "uwsgi-app@$app.socket"
|
||||||
|
systemctl stop "uwsgi-app@$app.service"
|
||||||
|
systemctl disable "uwsgi-app@$app.service"
|
||||||
yunohost service remove "uwsgi-app@$app"
|
yunohost service remove "uwsgi-app@$app"
|
||||||
|
|
||||||
ynh_secure_remove "$finaluwsgiini"
|
ynh_secure_remove "$finaluwsgiini"
|
||||||
|
|
|
@ -113,37 +113,6 @@ ynh_system_user_create "$app" "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
|
||||||
# create config file syncserver.ini
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Generate random password and save
|
|
||||||
secret=$(ynh_string_random)
|
|
||||||
ynh_app_setting_set "$app" secret "$secret"
|
|
||||||
|
|
||||||
# Copy Files
|
|
||||||
ynh_replace_string "__APP__" "$app" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__DOMAIN__" "$domain" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__NAME__" "$app" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__SECRET__" "$secret" "$finaluwsgiini"
|
|
||||||
|
|
||||||
ynh_replace_string "__DB_USER__" "$db_user" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__DB_NAME__" "$db_name" "$finaluwsgiini"
|
|
||||||
|
|
||||||
rm "$final_path/syncserver.ini"
|
|
||||||
ln -s "$finaluwsgiini" "$final_path/syncserver.ini"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MODIFY A CONFIG FILE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# TODO: fix this css patch
|
|
||||||
# ynh_replace_string "media\/img@$path_url\/media\/img@g" $final_path/syncserver/page/sync_files/firefox_sync-bundle.css
|
|
||||||
# ynh_replace_string "media\/img@$path_url\/media\/img@g" $final_path/syncserver/page/sync_files/responsive-bundle.css
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# pip installation
|
# pip installation
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -170,14 +139,6 @@ virtualenv "$final_path/local"
|
||||||
cp -r ../sources/page $final_path/syncserver/
|
cp -r ../sources/page $final_path/syncserver/
|
||||||
(cd "$final_path/syncserver" && patch -p1 < $YNH_CWD/../sources/homepage.patch) || echo "Unable to apply patches"
|
(cd "$final_path/syncserver" && patch -p1 < $YNH_CWD/../sources/homepage.patch) || echo "Unable to apply patches"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP UWSGI
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_add_uwsgi_service
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -185,6 +146,32 @@ ynh_add_uwsgi_service
|
||||||
chown $app -R $final_path
|
chown $app -R $final_path
|
||||||
chmod u=rwX,g=rX,o= -R $final_path
|
chmod u=rwX,g=rX,o= -R $final_path
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP UWSGI
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Generate random password and save
|
||||||
|
secret=$(ynh_string_random)
|
||||||
|
ynh_app_setting_set "$app" secret "$secret"
|
||||||
|
|
||||||
|
# create config file syncserver.ini
|
||||||
|
rm "$final_path/syncserver.ini"
|
||||||
|
ln -s "/etc/uwsgi/apps-available/$app.ini" "$final_path/syncserver.ini"
|
||||||
|
|
||||||
|
# configure uwsgi
|
||||||
|
ynh_add_uwsgi_service 'domain secret db_user db_pwd db_name'
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MODIFY A CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# TODO: fix this css patch
|
||||||
|
# ynh_replace_string "media\/img@$path_url\/media\/img@g" $final_path/syncserver/page/sync_files/firefox_sync-bundle.css
|
||||||
|
# ynh_replace_string "media\/img@$path_url\/media\/img@g" $final_path/syncserver/page/sync_files/responsive-bundle.css
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -197,10 +184,3 @@ ynh_use_logrotate /var/log/uwsgi/$app
|
||||||
|
|
||||||
# accessible by everyone (authentification is done by firefox accounts)
|
# accessible by everyone (authentification is done by firefox accounts)
|
||||||
ynh_app_setting_set "$app" skipped_uris "/"
|
ynh_app_setting_set "$app" skipped_uris "/"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
systemctl start "uwsgi-app@$app.service"
|
|
||||||
systemctl reload nginx
|
|
||||||
|
|
|
@ -98,12 +98,6 @@ ynh_install_app_dependencies python-dev python-virtualenv \
|
||||||
`# ARM support: ` \
|
`# ARM support: ` \
|
||||||
build-essential libssl-dev libffi-dev
|
build-essential libssl-dev libffi-dev
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC SETUP UWSGI
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_add_uwsgi_service
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -139,25 +133,6 @@ fi
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create "$app"
|
ynh_system_user_create "$app"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC UPGRADE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Copy Files
|
|
||||||
ynh_replace_string "__APP__" "$app" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__DOMAIN__" "$domain" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__NAME__" "$app" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__SECRET__" "$secret" "$finaluwsgiini"
|
|
||||||
|
|
||||||
ynh_replace_string "__DB_USER__" "$db_user" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$finaluwsgiini"
|
|
||||||
ynh_replace_string "__DB_NAME__" "$db_name" "$finaluwsgiini"
|
|
||||||
|
|
||||||
rm "$final_path/syncserver.ini"
|
|
||||||
ln -s "$finaluwsgiini" "$final_path/syncserver.ini"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# pip installation
|
# pip installation
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -184,8 +159,6 @@ virtualenv "$final_path/local"
|
||||||
cp -r ../sources/page $final_path/syncserver/
|
cp -r ../sources/page $final_path/syncserver/
|
||||||
(cd "$final_path/syncserver" && patch -p1 < $YNH_CWD/../sources/homepage.patch) || echo "Unable to apply patches"
|
(cd "$final_path/syncserver" && patch -p1 < $YNH_CWD/../sources/homepage.patch) || echo "Unable to apply patches"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -193,6 +166,19 @@ cp -r ../sources/page $final_path/syncserver/
|
||||||
chown $app -R $final_path
|
chown $app -R $final_path
|
||||||
chmod u=rwX,g=rX,o= -R $final_path
|
chmod u=rwX,g=rX,o= -R $final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP UWSGI
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# create config file syncserver.ini
|
||||||
|
rm "$final_path/syncserver.ini"
|
||||||
|
ln -s "/etc/uwsgi/apps-available/$app.ini" "$final_path/syncserver.ini"
|
||||||
|
|
||||||
|
# configure uwsgi
|
||||||
|
ynh_add_uwsgi_service 'domain secret db_user db_pwd db_name'
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue