mirror of
https://github.com/YunoHost-Apps/ffsync_ynh.git
synced 2024-09-03 18:26:38 +02:00
Add message and use getops for helper's args
This commit is contained in:
parent
5a7f39d219
commit
8a41d00064
9 changed files with 367 additions and 459 deletions
70
README.md
70
README.md
|
@ -1,4 +1,14 @@
|
|||
# Mozilla’s Sync Server for Yunohost
|
||||
Mozilla’s Sync Server for Yunohost
|
||||
==================================
|
||||
|
||||
[![Integration level](https://dash.yunohost.org/integration/ffsync.svg)](https://ci-apps.yunohost.org/ci/apps/ffsync%20%28Community%29/lastBuild/consoleFull)
|
||||
[![Install ffsync with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=ffsync)
|
||||
|
||||
> *This package allow you to install ffsync quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
The Sync Server provides a replacement for Firefox’s default server (hosted at Mozilla).
|
||||
|
||||
|
@ -6,13 +16,65 @@ By default, a server set up will defer authentication to the Mozilla-hosted acco
|
|||
|
||||
**Shipped version:** 1.8
|
||||
|
||||
## Configuring
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
* Official documentation: https://docs.services.mozilla.com/howtos/run-sync-1.5.html
|
||||
* YunoHost documentation: There no other documentations, feel free to contribute.
|
||||
|
||||
YunoHost specific features
|
||||
--------------------------
|
||||
|
||||
<!--Limitations
|
||||
-----------
|
||||
|
||||
* Any known limitations.-->
|
||||
|
||||
Additional informations
|
||||
-----------------------
|
||||
|
||||
### Configuring
|
||||
|
||||
Once installed, reaching `http://domain.tld/path` should show a page explaining how to configure it. Otherwise please refer to the [Yunohost page](https://yunohost.org/#/app_ffsync).
|
||||
|
||||
## Links
|
||||
|
||||
* Report a bug about this package: https://github.com/YunoHost-Apps/ffsync_ynh
|
||||
* Report a bug about this package: https://github.com/YunoHost-Apps/ffsync_ynh/issues
|
||||
* Report a bug about firefox sync itself: https://github.com/mozilla-services/syncserver
|
||||
* Documentation: https://docs.services.mozilla.com/howtos/run-sync-1.5.html
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
From command line:
|
||||
|
||||
`sudo yunohost app install -l ffsync https://github.com/YunoHost-Apps/ffsync_ynh`
|
||||
|
||||
Upgrade
|
||||
-------
|
||||
|
||||
From command line:
|
||||
|
||||
`sudo yunohost app upgrade ffsync -u https://github.com/YunoHost-Apps/ffsync_ynh`
|
||||
|
||||
Developers infos
|
||||
----------------
|
||||
|
||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/ffsync_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/ffsync_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade ffsync -u https://github.com/YunoHost-Apps/ffsync_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
ffsync is published under the Mozilla Public License Version 2.0
|
||||
|
||||
TODO
|
||||
----
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
},
|
||||
"previous_maintainers": [{
|
||||
"name": "beudbeud",
|
||||
"email": "beudbeud@beudibox.fr",
|
||||
"email": "beudbeud@beudibox.fr"
|
||||
}, {
|
||||
"name": "jibec",
|
||||
"email": "jean-baptiste@holcroft.fr"
|
||||
}],
|
||||
|
|
|
@ -1,128 +1,41 @@
|
|||
#!/bin/bash
|
||||
#=================================================
|
||||
# SET ALL CONSTANTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Note that we also need some specific dependances for build with arm architectures
|
||||
dependances="python-dev python-virtualenv virtualenv uwsgi uwsgi-plugin-python build-essential libssl-dev libffi-dev"
|
||||
|
||||
# Check if system wide templates are available and correcly configured
|
||||
#
|
||||
# usage: ynh_check_global_uwsgi_config
|
||||
ynh_check_global_uwsgi_config () {
|
||||
uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency"
|
||||
install_sources() {
|
||||
ynh_setup_source --dest_dir "$final_path"
|
||||
|
||||
cat > /etc/systemd/system/uwsgi-app@.service <<EOF
|
||||
[Unit]
|
||||
Description=%i uWSGI app
|
||||
After=syslog.target
|
||||
# pip installation
|
||||
virtualenv --python=$(which python2 python | head -n 1) "$final_path/local"
|
||||
# Init virtualenv
|
||||
(
|
||||
set +o nounset
|
||||
source "$final_path/local/bin/activate"
|
||||
set -o nounset
|
||||
cd "$final_path"
|
||||
pip install --upgrade pip
|
||||
pip install --upgrade pyramid_chameleon
|
||||
CFLAGS="-Wno-error -Wno-error=format-security" \
|
||||
ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" \
|
||||
pip install --upgrade --requirement "$final_path/requirements.txt"
|
||||
|
||||
[Service]
|
||||
RuntimeDirectory=%i
|
||||
ExecStart=/usr/bin/uwsgi \
|
||||
--ini /etc/uwsgi/apps-available/%i.ini \
|
||||
--socket /var/run/%i/app.socket \
|
||||
--logto /var/log/uwsgi/%i/%i.log
|
||||
User=%i
|
||||
Group=www-data
|
||||
Restart=on-failure
|
||||
KillSignal=SIGQUIT
|
||||
Type=notify
|
||||
StandardError=syslog
|
||||
NotifyAccess=all
|
||||
python "$final_path/setup.py" develop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
touch "$final_path/local/COMPLETE"
|
||||
)
|
||||
# Add nice homepage
|
||||
cp -r ../sources/page $final_path/syncserver/
|
||||
(cd "$final_path/syncserver" && patch -p1 < $YNH_CWD/../sources/homepage.patch) || echo "Unable to apply patches"
|
||||
}
|
||||
|
||||
# Create a dedicated uwsgi ini file to use with generic uwsgi service
|
||||
#
|
||||
# This will use a template in ../conf/uwsgi.ini
|
||||
# and will replace the following keywords with
|
||||
# global variables that should be defined before calling
|
||||
# this helper :
|
||||
#
|
||||
# __APP__ by $app
|
||||
# __PATH__ by $path_url
|
||||
# __FINALPATH__ by $final_path
|
||||
#
|
||||
# And dynamic variables (from the last example) :
|
||||
# __PATH_2__ by $path_2
|
||||
# __PORT_2__ by $port_2
|
||||
#
|
||||
# To be able to customise the settings of the systemd unit you can override the rules with the file "conf/uwsgi-app@override.service".
|
||||
# This file will be automatically placed on the good place
|
||||
#
|
||||
# usage: ynh_add_uwsgi_service
|
||||
#
|
||||
# to interact with your service: `systemctl <action> uwsgi-app@app`
|
||||
ynh_add_uwsgi_service () {
|
||||
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
|
||||
usermod --append --groups www-data "$app" || ynh_die "It wasn't possible to add user $app to group www-data"
|
||||
|
||||
ynh_backup_if_checksum_is_different "$finaluwsgiini"
|
||||
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
||||
|
||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
||||
# Substitute in a nginx config file only if the variable is not empty
|
||||
if test -n "${final_path:-}"; then
|
||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini"
|
||||
fi
|
||||
if test -n "${path_url:-}"; then
|
||||
ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini"
|
||||
fi
|
||||
if test -n "${app:-}"; then
|
||||
ynh_replace_string "__APP__" "$app" "$finaluwsgiini"
|
||||
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"
|
||||
|
||||
chown $app:root "$finaluwsgiini"
|
||||
|
||||
# make sure the folder for logs exists and set authorizations
|
||||
mkdir -p /var/log/uwsgi/$app
|
||||
chown $app:root /var/log/uwsgi/$app
|
||||
chmod -R u=rwX,g=rX,o= /var/log/uwsgi/$app
|
||||
|
||||
# Setup specific Systemd rules if necessary
|
||||
test -e ../conf/uwsgi-app@override.service && \
|
||||
mkdir /etc/systemd/system/uwsgi-app@$app.service.d && \
|
||||
cp ../conf/uwsgi-app@override.service /etc/systemd/system/uwsgi-app@$app.service.d/override.conf
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl stop "uwsgi-app@$app.service" || true
|
||||
systemctl enable "uwsgi-app@$app.service"
|
||||
systemctl start "uwsgi-app@$app.service"
|
||||
|
||||
# Add as a service
|
||||
yunohost service add "uwsgi-app@$app" --log "/var/log/uwsgi/$app/$app.log"
|
||||
}
|
||||
|
||||
# Remove the dedicated uwsgi ini file
|
||||
#
|
||||
# usage: ynh_remove_uwsgi_service
|
||||
ynh_remove_uwsgi_service () {
|
||||
local finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||
if [ -e "$finaluwsgiini" ]; then
|
||||
systemctl stop "uwsgi-app@$app.service"
|
||||
systemctl disable "uwsgi-app@$app.service"
|
||||
yunohost service remove "uwsgi-app@$app"
|
||||
|
||||
ynh_secure_remove "$finaluwsgiini"
|
||||
ynh_secure_remove "/var/log/uwsgi/$app"
|
||||
ynh_secure_remove "/etc/systemd/system/uwsgi-app@$app.service.d"
|
||||
fi
|
||||
set_permissions() {
|
||||
chown $app -R $final_path
|
||||
chmod u=rwX,g=rX,o= -R $final_path
|
||||
chown $app:root /var/log/uwsgi/$app
|
||||
chmod -R u=rwX,g=rX,o= /var/log/uwsgi/$app
|
||||
}
|
||||
|
|
|
@ -3,60 +3,46 @@
|
|||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# Import common cmd
|
||||
source ../settings/scripts/experimental_helper.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
db_name=$(ynh_app_setting_get --app $app --key db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the main app directory..."
|
||||
ynh_backup --src_path "$final_path"
|
||||
|
||||
ynh_backup "$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing configuration..."
|
||||
ynh_backup --src_path "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Backing up database"
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# Backup Log
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up logs"
|
||||
ynh_backup --src_path "/var/log/uwsgi/$app"
|
||||
|
||||
ynh_backup "/var/log/uwsgi/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE UWSGI FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up configuration..."
|
||||
ynh_backup --src_path "/etc/uwsgi/apps-available/$app.ini"
|
||||
ynh_backup --src_path "/etc/systemd/system/uwsgi-app@.service"
|
||||
|
||||
ynh_backup "/etc/uwsgi/apps-available/$app.ini"
|
||||
ynh_backup "/etc/systemd/system/uwsgi-app@.service"
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
||||
|
|
123
scripts/experimental_helper.sh
Normal file
123
scripts/experimental_helper.sh
Normal file
|
@ -0,0 +1,123 @@
|
|||
# Check if system wide templates are available and correcly configured
|
||||
#
|
||||
# usage: ynh_check_global_uwsgi_config
|
||||
ynh_check_global_uwsgi_config () {
|
||||
uwsgi --version || ynh_die --message "You need to add uwsgi (and appropriate plugin) as a dependency"
|
||||
|
||||
cat > /etc/systemd/system/uwsgi-app@.service <<EOF
|
||||
[Unit]
|
||||
Description=%i uWSGI app
|
||||
After=syslog.target
|
||||
|
||||
[Service]
|
||||
RuntimeDirectory=%i
|
||||
ExecStart=/usr/bin/uwsgi \
|
||||
--ini /etc/uwsgi/apps-available/%i.ini \
|
||||
--socket /var/run/%i/app.socket \
|
||||
--logto /var/log/uwsgi/%i/%i.log
|
||||
User=%i
|
||||
Group=www-data
|
||||
Restart=on-failure
|
||||
KillSignal=SIGQUIT
|
||||
Type=notify
|
||||
StandardError=syslog
|
||||
NotifyAccess=all
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
}
|
||||
|
||||
# Create a dedicated uwsgi ini file to use with generic uwsgi service
|
||||
#
|
||||
# This will use a template in ../conf/uwsgi.ini
|
||||
# and will replace the following keywords with
|
||||
# global variables that should be defined before calling
|
||||
# this helper :
|
||||
#
|
||||
# __APP__ by $app
|
||||
# __PATH__ by $path_url
|
||||
# __FINALPATH__ by $final_path
|
||||
#
|
||||
# And dynamic variables (from the last example) :
|
||||
# __PATH_2__ by $path_2
|
||||
# __PORT_2__ by $port_2
|
||||
#
|
||||
# To be able to customise the settings of the systemd unit you can override the rules with the file "conf/uwsgi-app@override.service".
|
||||
# This file will be automatically placed on the good place
|
||||
#
|
||||
# usage: ynh_add_uwsgi_service
|
||||
#
|
||||
# to interact with your service: `systemctl <action> uwsgi-app@app`
|
||||
ynh_add_uwsgi_service () {
|
||||
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
|
||||
usermod --append --groups www-data "$app" || ynh_die --message "It wasn't possible to add user $app to group www-data"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file "$finaluwsgiini"
|
||||
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
||||
|
||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
||||
# Substitute in a nginx config file only if the variable is not empty
|
||||
if test -n "${final_path:-}"; then
|
||||
ynh_replace_string --match_string __FINALPATH__ --replace_string "$final_path" --target_file "$finaluwsgiini"
|
||||
fi
|
||||
if test -n "${path_url:-}"; then
|
||||
ynh_replace_string --match_string __PATH__ --replace_string "$path_url" --target_file "$finaluwsgiini"
|
||||
fi
|
||||
if test -n "${app:-}"; then
|
||||
ynh_replace_string --match_string __APP__ --replace_string "$app" --target_file "$finaluwsgiini"
|
||||
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 --file "$finaluwsgiini"
|
||||
|
||||
chown $app:root "$finaluwsgiini"
|
||||
|
||||
# make sure the folder for logs exists and set authorizations
|
||||
mkdir -p /var/log/uwsgi/$app
|
||||
chown $app:root /var/log/uwsgi/$app
|
||||
chmod -R u=rwX,g=rX,o= /var/log/uwsgi/$app
|
||||
|
||||
# Setup specific Systemd rules if necessary
|
||||
test -e ../conf/uwsgi-app@override.service && \
|
||||
mkdir /etc/systemd/system/uwsgi-app@$app.service.d && \
|
||||
cp ../conf/uwsgi-app@override.service /etc/systemd/system/uwsgi-app@$app.service.d/override.conf
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl stop "uwsgi-app@$app.service" || true
|
||||
systemctl enable "uwsgi-app@$app.service"
|
||||
systemctl start "uwsgi-app@$app.service"
|
||||
|
||||
# Add as a service
|
||||
yunohost service add "uwsgi-app@$app" --log "/var/log/uwsgi/$app/$app.log"
|
||||
}
|
||||
|
||||
# Remove the dedicated uwsgi ini file
|
||||
#
|
||||
# usage: ynh_remove_uwsgi_service
|
||||
ynh_remove_uwsgi_service () {
|
||||
local finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||
if [ -e "$finaluwsgiini" ]; then
|
||||
systemctl stop "uwsgi-app@$app.service"
|
||||
systemctl disable "uwsgi-app@$app.service"
|
||||
yunohost service remove "uwsgi-app@$app"
|
||||
|
||||
ynh_secure_remove --file="$finaluwsgiini"
|
||||
ynh_secure_remove --file="/var/log/uwsgi/$app"
|
||||
ynh_secure_remove --file="/etc/systemd/system/uwsgi-app@$app.service.d"
|
||||
fi
|
||||
}
|
141
scripts/install
141
scripts/install
|
@ -3,163 +3,88 @@
|
|||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
# Import common cmd
|
||||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
|
||||
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_ARG_PATH)
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
final_path="/opt/yunohost/$app"
|
||||
|
||||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path "$path_url")
|
||||
# Generate random password and save
|
||||
secret=$(ynh_string_random)
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_app_setting_set --app $app --key final_path --value "$final_path"
|
||||
ynh_app_setting_set --app $app --key secret --value "$secret"
|
||||
|
||||
# Check destination directory
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
test ! -e "$final_path" || ynh_die --message "This path already contains a folder"
|
||||
|
||||
# Check web path availability
|
||||
ynh_webpath_available "$domain" "$path_url"
|
||||
# Register (book) web path
|
||||
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||
ynh_webpath_register --app $app --domain $domain --path_url $path_url
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
# Check depends installation
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=7
|
||||
ynh_install_app_dependencies $dependances
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
# Use 'FSyncMS' as database name and user
|
||||
ynh_script_progression --message="Configuring MySQL database..."
|
||||
db_user=$app
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
db_name=$(ynh_sanitize_dbid --db_name $app)
|
||||
ynh_app_setting_set --app $app --key db_name --value "$db_name"
|
||||
ynh_mysql_setup_db --db_user "$db_user" --db_name "$db_name"
|
||||
|
||||
ynh_app_setting_set "$app" db_name "$db_name"
|
||||
ynh_mysql_setup_db "$db_user" "$db_name"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
ynh_script_progression --message="Installing sources files..." --weight=10
|
||||
install_sources
|
||||
|
||||
# Modify assets to take path into account
|
||||
# TODO: try to include this as a patch if still needed
|
||||
# find ../sources/syncserver/page/sync_files/ -type f -exec sed -i -e "s@media\/img@$path_url\/media\/img@g" {} \;
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
ynh_script_progression --message="Configuring nginx"
|
||||
ynh_add_nginx_config
|
||||
|
||||
if [ "$path_url" == "/" ]
|
||||
then
|
||||
# $finalnginxconf comes from ynh_add_nginx_config
|
||||
# uwsgi_param is only needed for non-root installation
|
||||
ynh_replace_string "uwsgi_param " "#uwsgi_param " "$finalnginxconf"
|
||||
ynh_replace_string "uwsgi_modifier1 " "#uwsgi_modifier1 " "$finalnginxconf"
|
||||
ynh_replace_string --match_string "uwsgi_param " --replace_string "#uwsgi_param " --target_file "$finalnginxconf"
|
||||
ynh_replace_string --match_string "uwsgi_modifier1 " --replace_string "#uwsgi_modifier1 " --target_file "$finalnginxconf"
|
||||
fi
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
ynh_store_file_checksum --file "$finalnginxconf"
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
ynh_system_user_create "$app" "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# pip installation
|
||||
#=================================================
|
||||
|
||||
virtualenv --python=$(which python2 python | head -n 1) "$final_path/local"
|
||||
# Init virtualenv
|
||||
(
|
||||
set +o nounset
|
||||
source "$final_path/local/bin/activate"
|
||||
set -o nounset
|
||||
cd "$final_path"
|
||||
pip install --upgrade pip
|
||||
pip install --upgrade pyramid_chameleon
|
||||
CFLAGS="-Wno-error -Wno-error=format-security" \
|
||||
ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" \
|
||||
pip install --upgrade --requirement "$final_path/requirements.txt"
|
||||
|
||||
python "$final_path/setup.py" develop
|
||||
|
||||
touch "$final_path/local/COMPLETE"
|
||||
)
|
||||
|
||||
# Add nice homepage
|
||||
cp -r ../sources/page $final_path/syncserver/
|
||||
(cd "$final_path/syncserver" && patch -p1 < $YNH_CWD/../sources/homepage.patch) || echo "Unable to apply patches"
|
||||
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
chown $app -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"
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
ynh_system_user_create --username "$app" --home_dir "$final_path"
|
||||
|
||||
# create config file syncserver.ini
|
||||
ynh_script_progression --message="Configuring application..."
|
||||
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
|
||||
|
@ -167,8 +92,14 @@ ynh_add_uwsgi_service 'domain secret db_user db_pwd db_name'
|
|||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
ynh_script_progression --message="Protecting directory"
|
||||
set_permissions
|
||||
|
||||
# SETUP SSOWAT
|
||||
# accessible by everyone (authentification is done by firefox accounts)
|
||||
ynh_app_setting_set "$app" skipped_uris "/"
|
||||
ynh_script_progression --message="Configuring permissions"
|
||||
ynh_app_setting_set --app $app --key skipped_uris --value "/"
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -3,61 +3,50 @@
|
|||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# Stop script if errors
|
||||
set -u
|
||||
|
||||
# Import common cmd
|
||||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
||||
db_user=$app
|
||||
db_name=$app
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE UWSGI
|
||||
#=================================================
|
||||
|
||||
# REMOVE UWSGI
|
||||
ynh_script_progression --message="Removing configuration..."
|
||||
ynh_remove_uwsgi_service
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_script_progression --message="Removing dependencies" --weight=10
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing databases..."
|
||||
ynh_mysql_remove_db --db_user "$db_user" --db_name "$db_name"
|
||||
|
||||
ynh_mysql_remove_db "$db_user" "$db_name"
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the main app directory..."
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
ynh_secure_remove "$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removing nginx configuration"
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete "$app"
|
||||
ynh_script_progression --message="Removing user..."
|
||||
ynh_system_user_delete --username "$app"
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -3,100 +3,64 @@
|
|||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# Import common cmd
|
||||
source ../settings/scripts/experimental_helper.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
path_url=$(ynh_app_setting_get --app $app --key path)
|
||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
||||
db_name=$(ynh_app_setting_get --app $app --key db_name)
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
|
||||
ynh_webpath_available "$domain" "$path_url" \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
test ! -d "$final_path" \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
ynh_webpath_available --domain $domain --path_url $path_url || ynh_die --message "$domain/$path_url is not available, please use an other domain or path."
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
|
||||
# Restore all config and data
|
||||
ynh_script_progression --message="Restoring files..." --weight=5
|
||||
ynh_restore
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring database..." --weight=3
|
||||
db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
||||
ynh_mysql_setup_db --db_user "$db_name" --db_name "$db_name" --db_pwd "$db_pwd"
|
||||
ynh_mysql_connect_as --user "$db_name" --password "$db_pwd" --database "$db_name" < ./db.sql
|
||||
|
||||
db_pwd=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
ynh_mysql_setup_db "$db_name" "$db_name" "$db_pwd"
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
ynh_system_user_create --username "$app"
|
||||
usermod --append --groups www-data "$app"
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create "$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
chown $app -R $final_path
|
||||
chmod u=rwX,g=rX,o= -R $final_path
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
ynh_install_app_dependencies $dependances
|
||||
|
||||
# set authorizations
|
||||
chown $app:root /var/log/uwsgi/$app
|
||||
chmod -R u=rwX,g=rX,o= /var/log/uwsgi/$app
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
set_permissions
|
||||
|
||||
#=================================================
|
||||
# RESTORE SERVICE
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
yunohost service add "uwsgi-app@$app.service" --log "/var/log/uwsgi/app/$app"
|
||||
|
||||
usermod --append --groups www-data "$app"
|
||||
ynh_script_progression --message="Reloading services..." --weight=3
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable "uwsgi-app@$app.service"
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
yunohost service add "uwsgi-app@$app.service" --log "/var/log/uwsgi/app/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
|
||||
# RELOAD NGINX AND UWSGI
|
||||
systemctl start "uwsgi-app@$app.service"
|
||||
systemctl reload nginx
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
135
scripts/upgrade
135
scripts/upgrade
|
@ -3,54 +3,46 @@
|
|||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
# Import common cmd
|
||||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
db_pwd=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
# LOAD SETTINGS
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
path_url=$(ynh_app_setting_get --app $app --key path)
|
||||
db_name=$(ynh_app_setting_get --app $app --key db_name)
|
||||
db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
||||
db_user=$app
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
secret=$(ynh_app_setting_get "$app" secret)
|
||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
||||
secret=$(ynh_app_setting_get --app $app --key secret)
|
||||
path_url=$(ynh_normalize_url_path "$path_url")
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking backware compatibility..." --weight=10
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z "$db_name" ]; then
|
||||
db_name=$(ynh_sanitize_dbid "$app")
|
||||
ynh_app_setting_set $app db_name "$db_name"
|
||||
ynh_app_setting_set --app $app --key db_name --value "$db_name"
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/opt/yunohost/$app
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
ynh_app_setting_set --app $app --key final_path --value "$final_path"
|
||||
fi
|
||||
|
||||
# If path_url doesn't exist, create it
|
||||
if [ -z "$path_url" ]; then
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
ynh_app_setting_set "$app" path "$path_url"
|
||||
path_url=$(ynh_app_setting_get --app $app --key path)
|
||||
ynh_app_setting_set --app $app --key path --value "$path_url"
|
||||
ynh_app_setting_delete "$app" path
|
||||
fi
|
||||
|
||||
|
@ -59,54 +51,35 @@ if [ -e /etc/init.d/ffsync ]; then
|
|||
service ffsync stop
|
||||
update-rc.d -f ffsync remove
|
||||
|
||||
ynh_secure_remove /etc/init.d/ffsync
|
||||
ynh_secure_remove /var/log/ffsync.log
|
||||
ynh_secure_remove /opt/yunohost/ffsync
|
||||
ynh_secure_remove --file=/etc/init.d/ffsync
|
||||
ynh_secure_remove --file=/var/log/ffsync.log
|
||||
ynh_secure_remove --file=/opt/yunohost/ffsync
|
||||
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
||||
# Backup the current version of the app
|
||||
# Backup the current version of the ap
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK THE PATH
|
||||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path "$path_url")
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
# Check depends installation
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
ynh_install_app_dependencies $dependances
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=6
|
||||
install_sources
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_script_progression --message="Configuring nginx..."
|
||||
ynh_add_nginx_config
|
||||
|
||||
if [ "$path_url" == "/" ]
|
||||
|
@ -116,53 +89,14 @@ then
|
|||
ynh_replace_string "uwsgi_param " "#uwsgi_param " "$finalnginxconf"
|
||||
ynh_replace_string "uwsgi_modifier1 " "#uwsgi_modifier1 " "$finalnginxconf"
|
||||
fi
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
ynh_store_file_checksum --file "$finalnginxconf"
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create "$app"
|
||||
|
||||
#=================================================
|
||||
# pip installation
|
||||
#=================================================
|
||||
|
||||
virtualenv --python=$(which python2 python | head -n 1) "$final_path/local"
|
||||
# Init virtualenv
|
||||
(
|
||||
set +o nounset
|
||||
source "$final_path/local/bin/activate"
|
||||
set -o nounset
|
||||
cd "$final_path"
|
||||
pip install --upgrade pip
|
||||
pip install --upgrade pyramid_chameleon
|
||||
CFLAGS="-Wno-error -Wno-error=format-security" \
|
||||
ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" \
|
||||
pip install --upgrade --requirement "$final_path/requirements.txt"
|
||||
|
||||
python "$final_path/setup.py" develop
|
||||
|
||||
touch "$final_path/local/COMPLETE"
|
||||
)
|
||||
|
||||
# Add nice homepage
|
||||
cp -r ../sources/page $final_path/syncserver/
|
||||
(cd "$final_path/syncserver" && patch -p1 < $YNH_CWD/../sources/homepage.patch) || echo "Unable to apply patches"
|
||||
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
chown $app -R $final_path
|
||||
chmod u=rwX,g=rX,o= -R $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP UWSGI
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Configuring application..."
|
||||
# create config file syncserver.ini
|
||||
rm "$final_path/syncserver.ini"
|
||||
ln -s "/etc/uwsgi/apps-available/$app.ini" "$final_path/syncserver.ini"
|
||||
|
@ -173,7 +107,12 @@ ynh_add_uwsgi_service 'domain secret db_user db_pwd db_name'
|
|||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set "$app" skipped_uris "/"
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
set_permissions
|
||||
|
||||
# SETUP SSOWAT
|
||||
ynh_app_setting_set --app $app --key skipped_uris --value "/"
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
|
Loading…
Reference in a new issue