1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/adminer_ynh.git synced 2024-09-03 18:06:06 +02:00

Some fixes

This commit is contained in:
anmol26s 2018-09-16 18:17:00 +05:30
parent a0be7e4f17
commit 4e04464f0d
8 changed files with 71 additions and 165 deletions

View file

@ -1,10 +1,12 @@
;; Nom du test
# Commentaire ignoré
# See here for more information
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
root_access=0
# is_public="Yes" (PUBLIC|public=Yes|private=No)
is_public=1 (PUBLIC|public=1|private=0)
; Checks
pkg_linter=1
@ -23,6 +25,8 @@
Level 1=auto
Level 2=auto
Level 3=auto
# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it.
# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well.
Level 4=na
Level 5=auto
Level 6=auto

View file

@ -1,112 +1,13 @@
#!/bin/bash
# =============================================================================
# YUNOHOST 2.7 FORTHCOMING HELPERS
# =============================================================================
# Create a dedicated nginx config
# ============= FUTURE YUNOHOST HELPER =============
# Delete a file checksum from the app settings
#
# usage: ynh_add_nginx_config
ynh_add_nginx_config () {
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalnginxconf" 1
sudo cp ../conf/nginx.conf "$finalnginxconf"
# 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 "${path_url:-}"; then
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
fi
if test -n "${domain:-}"; then
ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf"
fi
if test -n "${port:-}"; then
ynh_replace_string "__PORT__" "$port" "$finalnginxconf"
fi
if test -n "${app:-}"; then
ynh_replace_string "__NAME__" "$app" "$finalnginxconf"
fi
if test -n "${final_path:-}"; then
ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf"
fi
ynh_store_checksum_config "$finalnginxconf"
sudo systemctl reload nginx
}
# Remove the dedicated nginx config
# $app should be defined when calling this helper
#
# usage: ynh_remove_nginx_config
ynh_remove_nginx_config () {
ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf"
sudo systemctl reload nginx
}
# Create a dedicated php-fpm config
#
# usage: ynh_add_fpm_config
ynh_add_fpm_config () {
finalphpconf="/etc/php5/fpm/pool.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalphpconf" 1
sudo cp ../conf/php-fpm.conf "$finalphpconf"
ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf"
ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf"
ynh_replace_string "__USER__" "$app" "$finalphpconf"
sudo chown root: "$finalphpconf"
ynh_store_file_checksum "$finalphpconf"
if [ -e "../conf/php-fpm.ini" ]
then
finalphpini="/etc/php5/fpm/conf.d/20-$app.ini"
ynh_compare_checksum_config "$finalphpini" 1
sudo cp ../conf/php-fpm.ini "$finalphpini"
sudo chown root: "$finalphpini"
ynh_store_checksum_config "$finalphpini"
fi
sudo systemctl reload php5-fpm
}
# Remove the dedicated php-fpm config
#
# usage: ynh_remove_fpm_config
ynh_remove_fpm_config () {
ynh_secure_remove "/etc/php5/fpm/pool.d/$app.conf"
ynh_secure_remove "/etc/php5/fpm/conf.d/20-$app.ini" 2>&1
sudo systemctl reload php5-fpm
}
# Create a dedicated systemd config
#
# usage: ynh_add_systemd_config
ynh_add_systemd_config () {
finalsystemdconf="/etc/systemd/system/$app.service"
ynh_compare_checksum_config "$finalsystemdconf" 1
sudo cp ../conf/systemd.service "$finalsystemdconf"
# 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" "$finalsystemdconf"
fi
if test -n "${app:-}"; then
ynh_replace_string "__APP__" "$app" "$finalsystemdconf"
fi
ynh_store_checksum_config "$finalsystemdconf"
sudo chown root: "$finalsystemdconf"
sudo systemctl enable $app
sudo systemctl daemon-reload
}
# Remove the dedicated systemd config
#
# usage: ynh_remove_systemd_config
ynh_remove_systemd_config () {
finalsystemdconf="/etc/systemd/system/$app.service"
if [ -e "$finalsystemdconf" ]; then
sudo systemctl stop $app
sudo systemctl disable $app
ynh_secure_remove "$finalsystemdconf"
fi
# usage: ynh_remove_file_checksum file
# | arg: file - The file for which the checksum will be deleted
ynh_delete_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete $app $checksum_setting_name
}

View file

@ -1,19 +1,22 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors

View file

@ -21,6 +21,13 @@ new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# CHECK THE SYNTAX OF THE PATHS
#=================================================
@ -62,15 +69,8 @@ then
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Store path_url setting
ynh_app_setting_set $app path_url "$path_url"
# Create a dedicated nginx config
ynh_add_nginx_config
if [ "$path_url" != "/" ]
then
ynh_replace_string "^#sub_path_only " "" "$nginx_conf_path"
fi
ynh_store_file_checksum "$nginx_conf_path"
fi
# Change the domain for nginx

View file

@ -58,15 +58,15 @@ ynh_app_setting_set "$app" root_access "$root_access"
# Copy source files
src_path=/var/www/$app
sudo mkdir -p $src_path
sudo mkdir -p $final_path
if [[ $root_access -eq 1 ]]; then
#copy files from with_root_access folder to the src_path
sudo cp -a ../sources/with_root_access/. $src_path
#copy files from with_root_access folder to the final_path
sudo cp -a ../sources/with_root_access/. $final_path
else
#copy files from root_access_disabled folder to the src_path
sudo cp -a ../sources/root_access_disabled/. $src_path
#copy files from root_access_disabled folder to the final_path
sudo cp -a ../sources/root_access_disabled/. $final_path
fi
#=================================================
@ -78,10 +78,10 @@ ynh_system_user_create $app
# Set permissions to app files
# you may need to make some file and/or directory writeable by www-data (nginx user)
sudo find $src_path -type f | xargs sudo chmod 644
sudo find $src_path -type d | xargs sudo chmod 755
sudo chown -R $app: $src_path
# Make some file and/or directory writeable by app user (nginx user)
sudo find $final_path -type f | xargs sudo chmod 644
sudo find $final_path -type d | xargs sudo chmod 755
sudo chown -R $app: $final_path
#=================================================
# NGINX CONFIGURATION
@ -89,12 +89,6 @@ sudo chown -R $app: $src_path
# Create a dedicated nginx config
ynh_add_nginx_config
if [ "$path_url" != "/" ]
then
ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
fi
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# PHP-FPM CONFIGURATION
@ -103,7 +97,6 @@ ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
# Create a dedicated php-fpm config
ynh_add_fpm_config
#=================================================
# SETUP SSOWAT
#=================================================

View file

@ -19,7 +19,7 @@ domain=$(ynh_app_setting_get $app domain)
final_path=$(ynh_app_setting_get $app final_path)
# Remove sources
sudo rm -rf /var/www/$app
ynh_secure_remove $final_path
#=================================================
# REMOVE NGINX CONFIGURATION

View file

@ -6,18 +6,17 @@
# IMPORT GENERIC HELPERS
#=================================================
if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -64,7 +63,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file "$final_path"
# Restore permissions to app files
# you may need to make some file and/or directory writeable by www-data (nginx user)
# you may need to make some file and/or directory writeable by app (nginx user)
sudo chown -R $app: "$final_path"

View file

@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
path_url=$(ynh_app_setting_get "$app" path)
final_path=$(ynh_app_setting_get $app final_path)
is_public=$(ynh_app_setting_get "$app" is_public)
root_access=$(ynh_app_setting_get "$app" root_access)
@ -40,6 +41,18 @@ if [ -z $final_path ]; then
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
@ -56,31 +69,24 @@ path_url=$(ynh_normalize_url_path $path_url)
ynh_system_user_create $app
# Copy source files
src_path=/var/www/$app
sudo rm -rf $src_path
sudo mkdir -p $src_path
sudo rm -rf $final_path
sudo mkdir -p $final_path
if [[ $root_access -eq 1 ]]; then
#copy files from with_root_access folder to the src_path
sudo cp -a ../sources/with_root_access/. $src_path
#copy files from with_root_access folder to the final_path
sudo cp -a ../sources/with_root_access/. $final_path
else
#copy files from root_access_disabled folder to the src_path
sudo cp -a ../sources/root_access_disabled/. $src_path
#copy files from root_access_disabled folder to the final_path
sudo cp -a ../sources/root_access_disabled/. $final_path
fi
# Files owned by root, www-data can just read
sudo find $src_path -type f | xargs sudo chmod 644
sudo find $src_path -type d | xargs sudo chmod 755
sudo chown -R $app: $src_path
sudo find $final_path -type f | xargs sudo chmod 644
sudo find $final_path -type d | xargs sudo chmod 755
sudo chown -R $app: $final_path
# Create a dedicated nginx config
ynh_add_nginx_config
if [ "$path_url" != "/" ]
then
ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
fi
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# PHP-FPM CONFIGURATION