1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/plume_ynh.git synced 2024-09-03 20:15:54 +02:00

apply example_ynh to scripts/install

This commit is contained in:
Yalh 2019-01-22 15:51:07 +01:00 committed by yalh76
parent 3e3cf157e2
commit dba382b827

View file

@ -90,6 +90,8 @@ ynh_app_setting_set $app random_key $random_key
# Find a free port
port=$(ynh_find_port 8095)
# Open this port > not needed for Plume, will be proxied by Nginx
#yunohost firewall allow --no-upnp TCP $port 2>&1
ynh_app_setting_set $app port $port
#=================================================
@ -106,15 +108,21 @@ ynh_app_setting_set $app port $port
ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git curl gcc make openssl libssl-dev pkg-config sqlite3 libsqlite3-dev
#=================================================
# DATABASE SETUP
# CREATE A POSTGRESQL DATABASE
#=================================================
# Create postgresql database
### Use these lines if you need a database for the application.
### `ynh_psql_test_if_first_run` will create a master password and set up global settings.
### If you're not using these lines:
### - Remove the section "BACKUP THE POSTGRESQL DATABASE" in the backup script
### - Remove also the section "REMOVE THE POSTGRESQL DATABASE" in the remove script
### - As well as the section "RESTORE THE POSTGRESQL DATABASE" in the restore script
ynh_psql_test_if_first_run
db_name="$app"
db_pwd=$(ynh_string_random 30)
ynh_app_setting_set "$app" psql_db "$db_name"
ynh_app_setting_set "$app" psqlpwd "$db_pwd"
ynh_psql_test_if_first_run
ynh_psql_create_user "$app" "$db_pwd"
ynh_psql_execute_as_root \
"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;"
@ -134,6 +142,46 @@ git clone https://github.com/Plume-org/Plume.git "$final_path/$app"
# Create the media directory, where uploads will be stored
(cd $final_path && mkdir media )
#=================================================
# NGINX CONFIGURATION
#=================================================
### `ynh_add_nginx_config` will use the file conf/nginx.conf
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
# Create a system user
ynh_system_user_create $app $final_path
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
### `ynh_add_fpm_config` is used to set up a PHP config.
### You can remove it if your app doesn't use PHP.
### `ynh_add_fpm_config` will use the files conf/php-fpm.conf and conf/php-fpm.ini
### If you're not using these lines:
### - You can remove these files in conf/.
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
### With the reload at the end of the script.
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
# Create a dedicated php-fpm config
#ynh_add_fpm_config
#=================================================
# SPECIFIC SETUP
#=================================================
# ...
#=================================================
# setup application config
sudo cp ../conf/.env $final_path/$app/.env
#=================================================
@ -147,13 +195,6 @@ ynh_replace_string "__DB_USER__" "$app" "$final_path/$app/.env"
ynh_replace_string "__KEY__" "$random_key" "$final_path/$app/.env"
#=================================================
# CREATE DEDICATED USER
#=================================================
# Create a system user
ynh_system_user_create $app $final_path
# Set right permissions
chown -R $app: $final_path
@ -183,15 +224,86 @@ fi
( cd $final_path/$app && sudo -u "$app" /var/www/$app/.cargo/bin/plm search init -p $final_path/$app )
#=================================================
# NGINX CONFIGURATION
# SETUP SYSTEMD
#=================================================
### `ynh_add_nginx_config` will use the file conf/nginx.conf
### `ynh_systemd_config` is used to configure a systemd script for an app.
### It can be used for apps that use sysvinit (with adaptation) or systemd.
### Have a look at the app to be sure this app needs a systemd script.
### `ynh_systemd_config` will use the file conf/systemd.service
### If you're not using these lines:
### - You can remove those files in conf/.
### - Remove the section "BACKUP SYSTEMD" in the backup script
### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script
### - As well as the section "RESTORE SYSTEMD" in the restore script
### - And the section "SETUP SYSTEMD" in the upgrade script
# Create a dedicated nginx config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
systemctl enable "$app"
systemctl start "$app"
sleep 30
# Set right permissions
#=================================================
# 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
# Set the app as temporarily public for curl call
#ynh_app_setting_set $app skipped_uris "/"
# Reload SSOwat config
#yunohost app ssowatconf
# Reload Nginx
#systemctl reload nginx
# Installation with curl
#ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
# Remove the public access
#if [ $is_public -eq 0 ]
#then
# ynh_app_setting_delete $app skipped_uris
#fi
#=================================================
# MODIFY A CONFIG FILE
#=================================================
### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax)
#ynh_replace_string "match_string" "replace_string" "$final_path/CONFIG_FILE"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
### `ynh_store_file_checksum` is used to store the checksum of a file.
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
### you can make a backup of this file before modifying it again if the admin had modified it.
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/.env"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
### For security reason, any app should set the permissions to root: before anything else.
### Then, if write authorization is needed, any access should be given only to directories
### that really need such authorization.
# Set permissions to app files
chown -R $app: $final_path
#=================================================
@ -209,6 +321,21 @@ chown -R $app: $final_path
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
### `yunohost service add` is a CLI yunohost command to add a service in the admin panel.
### You'll find the service in the 'services' section of YunoHost admin panel.
### This CLI command would be useless if the app does not have any services (systemd or sysvinit)
### If you're not using these lines:
### - You can remove these files in conf/.
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
### - As well as the section ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
#yunohost service add $app --log "/var/log/$app/APP.log"
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
#yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/APP.log"
#=================================================
# SETUP SSOWAT
@ -221,11 +348,6 @@ then
ynh_app_setting_set $app unprotected_uris "/"
fi
# Create a dedicated systemd config
ynh_add_systemd_config
systemctl enable "$app"
systemctl start "$app"
sleep 30
#=================================================
# RELOAD NGINX
#=================================================