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

Merge pull request #21 from YunoHost-Apps/example_ynh_tweaks

Misc tweaks
This commit is contained in:
yalh76 2019-03-13 22:50:29 +01:00 committed by GitHub
commit 90507faa3c
4 changed files with 30 additions and 89 deletions

View file

@ -25,22 +25,11 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
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
### The id of the app as stated in the manifest is available as $YNH_APP_ID
### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
### The app instance name is available as $YNH_APP_INSTANCE_NAME
### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
### The app instance name is probably what interests you most, since this is
### guaranteed to be unique. This is a good unique identifier to define installation path,
### db names, ...
app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
@ -54,9 +43,6 @@ ynh_print_info "Validating installation parameters..."
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register $app $domain $path_url
@ -68,37 +54,21 @@ ynh_print_info "Storing installation settings..."
ynh_app_setting_set $app domain $domain ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app final_path $final_path
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_print_info "Configuring firewall..."
### Use these lines if you have to open a port for the application
### `ynh_find_port` will find the first available port starting from the given port.
### If you're not using these lines:
### - Remove the section "CLOSE A PORT" in the remove script
# Find a free port # Find a free port
port=$(ynh_find_port 8095) port=$(ynh_find_port 8095)
# Open this port
#ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
ynh_app_setting_set $app port $port ynh_app_setting_set $app port $port
# Registering db name
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Installing dependencies..." ynh_print_info "Installing 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_print_info "Installing nodejs ..." ynh_print_info "Installing nodejs ..."
ynh_install_nodejs 8.9.3 ynh_install_nodejs 8.9.3
@ -114,37 +84,27 @@ ynh_print_info "Starting mongodb ..."
systemctl enable mongodb systemctl enable mongodb
systemctl restart mongodb systemctl restart mongodb
#=================================================
# CREATE A MONGODB DATABASE
#=================================================
ynh_print_info "Creating a MongoDB database..."
### Use these lines if you need a database for the application.
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
### The password will be stored as 'mysqlpwd' into the app settings,
### and will be available as $db_pwd
### If you're not using these lines:
### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script
### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
#ynh_mysql_setup_db $db_name $db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Setting up source files..." ynh_print_info "Setting up wekan source files..."
### `ynh_setup_source` is used to install an app from a zip or tar.gz file, ### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository. ### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src ### `ynh_setup_source` use the file conf/app.src
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"
ynh_print_info "Installing wekan npm dependencies ..."
# Install wekan dependencies
chown -R $app $final_path
pushd $final_path/programs/server
ynh_use_nodejs
npm install
popd
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -165,18 +125,6 @@ ynh_system_user_create $app "$final_path"
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#=================================================
# INSTALL WEKAN NPM DEPENDENCIES
#=================================================
ynh_print_info "Installing wekan npm dependencies ..."
# Install wekan dependencies
chown -R $app $final_path
pushd $final_path/programs/server
ynh_use_nodejs
npm install
popd
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
@ -206,7 +154,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_print_info "Fixing permissions ..." ynh_print_info "Configuring file permissions ..."
### For security reason, any app should set the permissions to root: before anything else. ### 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 ### Then, if write authorization is needed, any access should be given only to directories
@ -253,6 +201,7 @@ systemctl reload nginx
#================================================= #=================================================
# START SERVICE # START SERVICE
#================================================= #=================================================
ynh_print_info "Now starting Wekan service..."
ynh_systemd_action --action=start --service_name=$app --log_path="systemd" --line_match="Finishing add-custom-html-before-body-end migration" ynh_systemd_action --action=start --service_name=$app --log_path="systemd" --line_match="Finishing add-custom-html-before-body-end migration"
sleep 10 sleep 10

View file

@ -82,16 +82,6 @@ ynh_print_info "Removing nginx web server configuration"
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
ynh_print_info "Closing port $port"
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -106,6 +106,7 @@ mongorestore --db $db_name ./dump/$db_name
ynh_print_info "Restoring the systemd configuration..." ynh_print_info "Restoring the systemd configuration..."
ynh_restore_file "/etc/systemd/system/$app.service" ynh_restore_file "/etc/systemd/system/$app.service"
systemctl daemon-reload
systemctl enable $app.service systemctl enable $app.service
#================================================= #=================================================
@ -127,6 +128,7 @@ systemctl reload nginx
#================================================= #=================================================
# START SERVICE # START SERVICE
#================================================= #=================================================
ynh_print_info "Now starting Wekan service..."
ynh_systemd_action --action=start --service_name=$app --log_path="systemd" ynh_systemd_action --action=start --service_name=$app --log_path="systemd"
sleep 10 sleep 10

View file

@ -25,6 +25,7 @@ final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get $app db_name)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get $app port)
# Previous versions of the app did not have the db_name setting
if [ -z "$db_name" ] if [ -z "$db_name" ]
then then
db_name=$app db_name=$app
@ -69,7 +70,6 @@ fi
if ynh_version_gt "0.77-2" "${previous_version}" ; then if ynh_version_gt "0.77-2" "${previous_version}" ; then
ynh_install_nodejs 8.9.3 ynh_install_nodejs 8.9.3
ynh_use_nodejs
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_replace_string "__ENV_PATH__" "$nodejs_path" "../conf/systemd.service" ynh_replace_string "__ENV_PATH__" "$nodejs_path" "../conf/systemd.service"
ynh_replace_string "__DB_NAME__" "$db_name" "../conf/systemd.service" ynh_replace_string "__DB_NAME__" "$db_name" "../conf/systemd.service"
@ -89,7 +89,6 @@ if ynh_version_gt "1.07~ynh2" "${previous_version}" ; then
yunohost service add mongodb --log "/var/log/mongodb/mongodb.log" yunohost service add mongodb --log "/var/log/mongodb/mongodb.log"
# Gotta regen the systemd config because mongodb service name changed # Gotta regen the systemd config because mongodb service name changed
ynh_use_nodejs
ynh_replace_string "__ENV_PATH__" "$nodejs_path" "../conf/systemd.service" ynh_replace_string "__ENV_PATH__" "$nodejs_path" "../conf/systemd.service"
ynh_replace_string "__DB_NAME__" "$db_name" "../conf/systemd.service" ynh_replace_string "__DB_NAME__" "$db_name" "../conf/systemd.service"
ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service" ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service"
@ -166,6 +165,7 @@ systemctl reload nginx
#================================================= #=================================================
# START SERVICE # START SERVICE
#================================================= #=================================================
ynh_print_info "Now restarting Wekan service..."
ynh_systemd_action --action=restart --service_name=$app --log_path="systemd" ynh_systemd_action --action=restart --service_name=$app --log_path="systemd"
sleep 10 sleep 10