mirror of
https://github.com/YunoHost-Apps/plume_ynh.git
synced 2024-09-03 20:15:54 +02:00
Update to 0.2.0 (Alpha 1) (#2)
* Plublic app temp upgrade * started backup and restore script * Updated to first alpha version * fix path * Added .env file * use openssl for genrating radom key * test spawn to input commands * test here string to input command * test spawn to input commands * test spawn to input commands * test spawn to input commands * test spawn to input commands * Removed spawn as no way to run export in it * Removed spawn as no way to run export in it
This commit is contained in:
parent
9796bb9362
commit
c298181b25
12 changed files with 203 additions and 188 deletions
|
@ -6,7 +6,6 @@
|
||||||
;; Test complet
|
;; Test complet
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld" (DOMAIN)
|
||||||
path="/path" (PATH)
|
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1 (PUBLIC|public=1|private=0)
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
|
|
6
conf/.env
Normal file
6
conf/.env
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
DB_URL=postgres://__DB_USER__:__PSQLPWD__@localhost:5432/__DBNAME__
|
||||||
|
BASE_URL=__DOMAIN__
|
||||||
|
|
||||||
|
ROCKET_PORT=__PORT__
|
||||||
|
ROCKET_ADDRESS=127.0.0.1
|
|
@ -1,6 +1,6 @@
|
||||||
SOURCE_URL=https://github.com/Plume-org/Plume/archive/ae8f8a1411a58236dee9ea561f05431e1c225d4f.zip
|
SOURCE_URL=https://github.com/Plume-org/Plume/archive/0.2.0-alpha-1.tar.gz
|
||||||
SOURCE_SUM=82b23a2da1077128c2f30e4d1ee29fa57b6a206038424f5589e1601223cf5b20
|
SOURCE_SUM=5e825275e00420bb3fb3fbac496b2ffb310d84ffab8c872293e7d73f752917b2
|
||||||
SOURCE_SUM_PRG=sha256sum
|
SOURCE_SUM_PRG=sha256sum
|
||||||
SOURCE_FORMAT=zip
|
SOURCE_FORMAT=tar.gz
|
||||||
SOURCE_IN_SUBDIR=true
|
SOURCE_IN_SUBDIR=true
|
||||||
SOURCE_FILENAME=
|
SOURCE_FILENAME=
|
||||||
|
|
64
conf/first_run.exp
Normal file
64
conf/first_run.exp
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
#!/usr/bin/expect
|
||||||
|
|
||||||
|
set final_path [lindex $argv 0]
|
||||||
|
set domain [lindex $argv 1]
|
||||||
|
set blog_name [lindex $argv 2]
|
||||||
|
set admin [lindex $argv 3]
|
||||||
|
set email [lindex $argv 4]
|
||||||
|
set port [lindex $argv 5]
|
||||||
|
|
||||||
|
|
||||||
|
cd $final_path
|
||||||
|
export PATH="$PATH:/root/.cargo/bin:$final_path/.local/bin:/usr/local/sbin"
|
||||||
|
|
||||||
|
spawn cargo run
|
||||||
|
|
||||||
|
expect "First let's check that you have all the required dependencies. Press Enter to start."
|
||||||
|
|
||||||
|
send "\r";
|
||||||
|
|
||||||
|
expect "Password:"
|
||||||
|
|
||||||
|
send {__PASSWORD__};
|
||||||
|
|
||||||
|
send "\r";
|
||||||
|
|
||||||
|
expect "Do you prefer a simple setup, or to customize everything?
|
||||||
|
1 - Simple setup
|
||||||
|
2 - Complete setup"
|
||||||
|
|
||||||
|
send "2\r";
|
||||||
|
|
||||||
|
expect "What is your instance domain?"
|
||||||
|
|
||||||
|
send "$domain\r";
|
||||||
|
|
||||||
|
expect "What is your instance name?"
|
||||||
|
|
||||||
|
send "$blog_name\r";
|
||||||
|
|
||||||
|
expect "What is your username? (default: admin)"
|
||||||
|
|
||||||
|
send "$admin\r";
|
||||||
|
|
||||||
|
expect "What is your email?"
|
||||||
|
|
||||||
|
send "$email\r";
|
||||||
|
|
||||||
|
expect "What is your password?"
|
||||||
|
|
||||||
|
send {__ADMIN_PASS__};
|
||||||
|
|
||||||
|
send "\r";
|
||||||
|
|
||||||
|
expect "On which port should Plume listen? (default: 7878)"
|
||||||
|
|
||||||
|
send "$port\r";
|
||||||
|
|
||||||
|
expect "On which address should Plume listen? (default: 0.0.0.0)"
|
||||||
|
|
||||||
|
send "127.0.0.1\r";
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
interact
|
22
conf/instance.txt
Normal file
22
conf/instance.txt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
INSERT INTO instances (
|
||||||
|
public_domain,
|
||||||
|
name,
|
||||||
|
local,
|
||||||
|
long_description,
|
||||||
|
short_description,
|
||||||
|
default_license,
|
||||||
|
open_registrations,
|
||||||
|
short_description_html,
|
||||||
|
long_description_html
|
||||||
|
) VALUES (
|
||||||
|
domain_name,
|
||||||
|
instance_name,
|
||||||
|
't',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'CC-0',
|
||||||
|
't',
|
||||||
|
'',
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
47
conf/pass.txt
Normal file
47
conf/pass.txt
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* to generate the password, in a shell */
|
||||||
|
|
||||||
|
apt install python-bcrypt
|
||||||
|
python -c 'import bcrypt; print(bcrypt.hashpw("PASSWORD", bcrypt.gensalt(log_rounds=10)))'
|
||||||
|
|
||||||
|
/* to generate the keypair, in a shell */
|
||||||
|
|
||||||
|
openssl genrsa -passout pass:PASSWORD -out private.pem 2048
|
||||||
|
openssl rsa -in private.pem -passin pass:PASSWORD -pubout -out public.pub
|
||||||
|
|
||||||
|
/** private.pem now contains the private key, public.pub the public one **/
|
||||||
|
|
||||||
|
/* SQL command to create the user */
|
||||||
|
|
||||||
|
INSERT INTO users (
|
||||||
|
username,
|
||||||
|
display_name,
|
||||||
|
outbox_url,
|
||||||
|
inbox_url,
|
||||||
|
is_admin,
|
||||||
|
summary,
|
||||||
|
email,
|
||||||
|
hashed_password,
|
||||||
|
instance_id,
|
||||||
|
ap_url,
|
||||||
|
public_key,
|
||||||
|
private_key,
|
||||||
|
shared_inbox_url,
|
||||||
|
followers_endpoint,
|
||||||
|
avatar_id,
|
||||||
|
) VALUES (
|
||||||
|
username,
|
||||||
|
display_name,
|
||||||
|
'https://' || domain_name || '/@/' || username || '/outbox',
|
||||||
|
'https://' || domain_name || '/@/' || username || '/inbox',
|
||||||
|
't',
|
||||||
|
'Admin of ' || instance_name,
|
||||||
|
email,
|
||||||
|
hashed_password,
|
||||||
|
1,
|
||||||
|
'https://' || domain_name || '/@/' || username,
|
||||||
|
pub_key,
|
||||||
|
priv_key,
|
||||||
|
'https://' || domain_name || '/inbox',
|
||||||
|
'https://' || domain_name || '/inbox',
|
||||||
|
NULL
|
||||||
|
);
|
|
@ -6,7 +6,7 @@ After=network.target
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/
|
WorkingDirectory=__FINALPATH__/
|
||||||
ExecStart=__FINALPATH__/ cargo run >> /var/log/__APP__/__APP__.log 2>&1
|
ExecStart=/bin/sh -c 'cargo run' >> /var/log/__APP__/__APP__.log 2>&1
|
||||||
TimeoutSec=30
|
TimeoutSec=30
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Package for Plume application."
|
"en": "Package for Plume application."
|
||||||
},
|
},
|
||||||
"version": "1.0~ynh1",
|
"version": "0.2.0",
|
||||||
"url": "https://baptiste.gelez.xyz/",
|
"url": "https://baptiste.gelez.xyz/",
|
||||||
"license": "free",
|
"license": "free",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -30,16 +30,6 @@
|
||||||
},
|
},
|
||||||
"example": "example.com"
|
"example": "example.com"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "path",
|
|
||||||
"type": "path",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose a path for Plume"
|
|
||||||
},
|
|
||||||
"example": "/example",
|
|
||||||
"default": "/example"
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
source psql.sh
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
|
@ -28,7 +29,8 @@ 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" psql_db)
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD BACKUP STEPS
|
# STANDARD BACKUP STEPS
|
||||||
|
@ -45,17 +47,11 @@ ynh_backup "$final_path"
|
||||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE PHP-FPM CONFIGURATION
|
# BACKUP THE PostgreSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
|
ynh_psql_dump_db "$db_name" > db.sql
|
||||||
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
|
ynh_backup "db.sql"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP THE MYSQL DATABASE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_mysql_dump_db "$db_name" > db.sql
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
|
@ -71,8 +67,3 @@ ynh_backup "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
ynh_backup "/etc/systemd/system/$app.service"
|
ynh_backup "/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP A CRON FILE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_backup "/etc/cron.d/$app"
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url=$YNH_APP_ARG_PATH
|
path_url="/"
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||||
|
@ -93,7 +93,7 @@ ynh_app_setting_set $app port $port
|
||||||
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
||||||
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||||
|
|
||||||
ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git curl gcc make openssl libssl-dev
|
ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git curl gcc make openssl libssl-dev pkg-config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DATABASE SETUP
|
# DATABASE SETUP
|
||||||
|
@ -121,6 +121,9 @@ ynh_app_setting_set $app final_path $final_path
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source "$final_path"
|
ynh_setup_source "$final_path"
|
||||||
|
|
||||||
|
# Create the media directory, where uploads will be stored
|
||||||
|
(cd $final_path && mkdir media )
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -128,11 +131,11 @@ ynh_setup_source "$final_path"
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create $app $final_path
|
ynh_system_user_create $app $final_path
|
||||||
|
|
||||||
( cd $final_path && curl -sf -L https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly --date=2018-05-31 )
|
( cd $final_path && curl -sf -L https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly --date=2018-07-17 )
|
||||||
export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin"
|
export PATH="$PATH:/root/.cargo/bin:$final_path/.local/bin:/usr/local/sbin"
|
||||||
( cd $final_path && cargo build )
|
( cd $final_path && cargo build )
|
||||||
( cd $final_path && cargo install diesel_cli --no-default-features --features postgres --version '=1.2.0' )
|
( cd $final_path && cargo install diesel_cli --no-default-features --features postgres --version '=1.2.0' )
|
||||||
( cd $final_path && diesel migration run --database-url postgres://$db_name:$db_pwd@localhost:5432/plume )
|
( cd $final_path && diesel migration run --database-url postgres://$db_name:$db_pwd@localhost:5432/$app )
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -143,12 +146,19 @@ export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
# setup application config
|
||||||
|
sudo cp ../conf/.env $final_path/.env
|
||||||
|
#=================================================
|
||||||
|
# MODIFY A CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
ynh_replace_string "__DBNAME__" "$db_name" "$final_path/.env"
|
||||||
|
ynh_replace_string "__PSQLPWD__" "$db_pwd" "$final_path/.env"
|
||||||
|
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/.env"
|
||||||
|
ynh_replace_string "__PORT__" "$port" "$final_path/.env"
|
||||||
|
ynh_replace_string "__DB_USER__" "$app" "$final_path/.env"
|
||||||
|
|
||||||
#=================================================
|
# Set right permissions
|
||||||
# SPECIFIC SETUP
|
chown -R $app: $final_path
|
||||||
#=================================================
|
|
||||||
# ...
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -166,26 +176,8 @@ ynh_add_nginx_config
|
||||||
### - And the section "SETUP SYSTEMD" in the upgrade script
|
### - And the section "SETUP SYSTEMD" in the upgrade script
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
# ynh_add_systemd_config
|
||||||
|
|
||||||
# Optional, only do it if the database URL is not
|
|
||||||
# postgres://plume:plume@localhost/plume
|
|
||||||
( cd $final_path && export DB_URL=postgres://$db_name:$db_pwd@localhost:5432/plume )
|
|
||||||
|
|
||||||
# Create the media directory, where uploads will be stored
|
|
||||||
(cd $final_path && mkdir media )
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP APPLICATION WITH CURL
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
### Use these lines only if the app installation needs to be finalized through
|
|
||||||
### web forms. We generally don't want to ask the final user,
|
|
||||||
### so we're going to use curl to automatically fill the fields and submit the
|
|
||||||
### forms.
|
|
||||||
|
|
||||||
# Set right permissions for curl install
|
|
||||||
chown -R $app: $final_path
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
source psql.sh
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
|
@ -29,7 +30,9 @@ 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)
|
port=$(ynh_app_setting_get "$app" port)
|
||||||
|
db_name=$(ynh_app_setting_get "$app" psql_db)
|
||||||
|
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
@ -39,6 +42,20 @@ ynh_webpath_available $domain $path_url \
|
||||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||||
test ! -d $final_path \
|
test ! -d $final_path \
|
||||||
|| ynh_die "There is already a directory: $final_path "
|
|| ynh_die "There is already a directory: $final_path "
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
||||||
|
### Those deb packages will be installed as dependencies of this package.
|
||||||
|
### If you're not using this helper:
|
||||||
|
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
||||||
|
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
||||||
|
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||||
|
|
||||||
|
ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git curl gcc make openssl libssl-dev
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
|
@ -53,14 +70,20 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file "$final_path"
|
||||||
|
( cd $final_path && curl -sf -L https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly --date=2018-05-31 )
|
||||||
|
|
||||||
|
# open port
|
||||||
|
yunohost firewall allow --no-upnp TCP $port 2>&1
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# RESTORE THE PostgreSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
ynh_psql_test_if_first_run
|
||||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
ynh_psql_create_user "$app" "$db_pwd"
|
||||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
ynh_psql_execute_as_root \
|
||||||
|
"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;"
|
||||||
|
ynh_psql_execute_file_as_root ./db.sql "$db_name"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
|
@ -74,29 +97,7 @@ ynh_system_user_create $app
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Restore permissions on app files
|
# Restore permissions on app files
|
||||||
chown -R root: $final_path
|
chown -R $app: $final_path
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
|
|
||||||
ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC RESTORATION
|
|
||||||
#=================================================
|
|
||||||
# REINSTALL DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Define and install dependencies
|
|
||||||
ynh_install_app_dependencies deb1 deb2
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
yunohost service add $app --log "/var/log/$app/APP.log"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEMD
|
||||||
|
@ -105,12 +106,6 @@ yunohost service add $app --log "/var/log/$app/APP.log"
|
||||||
ynh_restore_file "/etc/systemd/system/$app.service"
|
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||||
systemctl enable $app.service
|
systemctl enable $app.service
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE CRON FILE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_restore_file "/etc/cron.d/$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -120,8 +115,7 @@ ynh_restore_file "/etc/logrotate.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
systemctl reload php5-fpm
|
|
||||||
systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
|
@ -17,11 +17,9 @@ 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)
|
||||||
admin=$(ynh_app_setting_get $app admin)
|
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
language=$(ynh_app_setting_get $app language)
|
db_name=$(ynh_app_setting_get "$app" psql_db)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
@ -36,30 +34,10 @@ elif [ "$is_public" = "No" ]; then
|
||||||
is_public=0
|
is_public=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 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
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If final_path doesn't exist, create it
|
|
||||||
if [ -z $final_path ]; then
|
|
||||||
final_path=/var/www/$app
|
|
||||||
ynh_app_setting_set $app final_path $final_path
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Backup the current version of the app
|
|
||||||
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
|
# CHECK THE PATH
|
||||||
|
@ -68,76 +46,8 @@ ynh_abort_if_errors
|
||||||
# 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
|
|
||||||
#=================================================
|
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
|
||||||
ynh_setup_source "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPGRADE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_install_app_dependencies deb1 deb2
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
|
||||||
ynh_system_user_create $app
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# PHP-FPM CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Create a dedicated php-fpm config
|
|
||||||
ynh_add_fpm_config
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC UPGRADE
|
|
||||||
#=================================================
|
|
||||||
# ...
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
|
||||||
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
|
||||||
ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE"
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
|
||||||
ynh_store_file_checksum "$final_path/CONFIG_FILE"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP LOGROTATE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Use logrotate to manage app-specific logfile(s)
|
|
||||||
ynh_use_logrotate --non-append
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SYSTEMD
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
|
||||||
ynh_add_systemd_config
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# SECURE FILES AND DIRECTORIES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Set permissions on app files
|
|
||||||
chown -R root: $final_path
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
|
Loading…
Add table
Reference in a new issue