1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

[ehn] Factorize code between install and restore

Fix #13
This commit is contained in:
Jocelyn Delalande 2017-06-19 09:35:17 +02:00
parent 546581d642
commit a949dc1872
3 changed files with 22 additions and 16 deletions

View file

@ -43,6 +43,22 @@ fix_permissions() {
} }
install_apt_dependencies() {
sudo apt-get install -y -qq python-dev python-virtualenv supervisor libmysqlclient-dev
}
create_unix_user() {
sudo mkdir -p /opt/yunohost
sudo useradd ihatemoney -d /opt/yunohost/ihatemoney/ --create-home || ynh_die "User creation failed"
}
create_system_dirs() {
sudo install -o ihatemoney -g ihatemoney -m 755 -d \
/var/log/ihatemoney \
/etc/ihatemoney
sudo mkdir -p /opt/yunohost
}
### Backported helpers (from testing) ### Backported helpers (from testing)

View file

@ -56,12 +56,9 @@ trap exit_properly ERR
ynh_app_setting_set $app domain $domain ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app is_public "$is_public" ynh_app_setting_set $app is_public "$is_public"
# Install debian packages dependencies install_apt_dependencies
sudo apt-get install -y -qq python-dev python-virtualenv supervisor libmysqlclient-dev
# Create the dedicated user create_unix_user
sudo mkdir -p /opt/yunohost
sudo useradd ihatemoney -d /opt/yunohost/ihatemoney/ --create-home
# Install source # Install source
fetch_and_extract /opt/yunohost/ihatemoney/src/ ihatemoney fetch_and_extract /opt/yunohost/ihatemoney/src/ ihatemoney
@ -74,9 +71,7 @@ sudo /opt/yunohost/ihatemoney/venv/bin/pip install gunicorn>=19.3.0 MySQL-python
# Fix permissions # Fix permissions
fix_permissions /opt/yunohost/ihatemoney/src fix_permissions /opt/yunohost/ihatemoney/src
# Create various dirs create_system_dirs
sudo install -o ihatemoney -g ihatemoney -m 755 \
-d /var/log/ihatemoney /etc/ihatemoney
# Configure gunicorn # Configure gunicorn
sudo install -o ihatemoney -g ihatemoney -m 644 \ sudo install -o ihatemoney -g ihatemoney -m 644 \

View file

@ -46,12 +46,9 @@ test -f $gunicorn_conf_path && ynh_die \
"The Gunicorn configuration already exists at '${gunicorn_conf_path}'. "The Gunicorn configuration already exists at '${gunicorn_conf_path}'.
You should safely delete it before restoring this app." You should safely delete it before restoring this app."
# Install debian packages dependencies install_apt_dependencies
sudo apt-get install -y -qq python-dev python-virtualenv supervisor libmysqlclient-dev
# Create the dedicated user create_unix_user
sudo mkdir -p /opt/yunohost/
sudo useradd ihatemoney -d /opt/yunohost/ihatemoney/ --create-home
# Restore the app files # Restore the app files
sudo cp -a ./install_dir/. "$INSTALL_DIR" sudo cp -a ./install_dir/. "$INSTALL_DIR"
@ -61,9 +58,7 @@ fix_permissions ${INSTALL_DIR}/src
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
# Create various dirs create_system_dirs
sudo install -o ihatemoney -g ihatemoney -m 755 \
-d /var/log/ihatemoney /etc/ihatemoney
# Restore settings # Restore settings
sudo cp -a "conf/nginx.conf" "$nginx_conf_path" sudo cp -a "conf/nginx.conf" "$nginx_conf_path"