mirror of
https://github.com/YunoHost-Apps/ulogger_ynh.git
synced 2024-10-01 13:34:45 +02:00
commit
438604579a
15 changed files with 141 additions and 151 deletions
|
@ -9,7 +9,11 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
|
||||||
## Overview
|
## Overview
|
||||||
This is a web application for real-time collection of geolocation data, tracks viewing and management. Together with a dedicated [μlogger mobile client](https://github.com/bfabiszewski/ulogger-android) it may be used as a complete self hosted server–client solution for logging and monitoring users' geolocation.
|
This is a web application for real-time collection of geolocation data, tracks viewing and management. Together with a dedicated [μlogger mobile client](https://github.com/bfabiszewski/ulogger-android) it may be used as a complete self hosted server–client solution for logging and monitoring users' geolocation.
|
||||||
|
|
||||||
**Version:** 0.5
|
**Version:** 1.0
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
* [Official demo](http://ulogger.fabiszewski.net/) (login: demo, password: demo)
|
* [Official demo](http://ulogger.fabiszewski.net/) (login: demo, password: demo)
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
# See here for more informations
|
# See here for more informations
|
||||||
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
# 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
|
;; Test complet
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld" (DOMAIN)
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
INSERT INTO `users` (`id`, `login`, `password`) VALUES (NULL, '__admin__', '__admin_pwd__');
|
INSERT INTO `users` (`id`, `login`, `password`) VALUES (NULL, '__ADMIN__', '__ADMIN_PWD__');
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_URL=https://github.com/bfabiszewski/ulogger-server/archive/v0.5.zip
|
SOURCE_URL=https://github.com/bfabiszewski/ulogger-server/archive/v1.0.zip
|
||||||
SOURCE_SUM=77205e03323ab7aab46f2115e578357dd65b1ba8476d9d348ae3dc216f58a4d3
|
SOURCE_SUM=aac2f69f64477b3a1c4265d19603fa32d9ba385f3e00358c0a4f08e7dcbb2020
|
||||||
SOURCE_SUM_PRG=sha256sum
|
SOURCE_SUM_PRG=sha256sum
|
||||||
SOURCE_FORMAT=zip
|
SOURCE_FORMAT=zip
|
||||||
SOURCE_IN_SUBDIR=true
|
SOURCE_IN_SUBDIR=true
|
||||||
|
|
|
@ -16,68 +16,26 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// This is default configuration file.
|
// This is default configuration file.
|
||||||
// Copy it to config.php and customize
|
// Copy it to config.php and customize
|
||||||
// default map drawing framework
|
|
||||||
//$mapapi = "gmaps"; // google maps
|
// Database config
|
||||||
//$mapapi = "openlayers"; // openlayers 2
|
|
||||||
$mapapi = "openlayers3"; // openlayers 3+
|
// PDO data source name, eg.:
|
||||||
// openlayers additional map layers in XYZ format
|
// mysql:host=localhost;port=3307;dbname=ulogger;charset=utf8
|
||||||
// name => url
|
// mysql:unix_socket=/tmp/mysql.sock;dbname=ulogger;charset=utf8
|
||||||
$ol_layers['OpenCycleMap'] = 'https://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png'; // ?apikey=[API_KEY]
|
// pgsql:host=localhost;port=5432;dbname=ulogger
|
||||||
$ol_layers['OpenTopoMap'] = 'https://{a-c}.tile.opentopomap.org/{z}/{x}/{y}.png';
|
// sqlite:/tmp/ulogger.db
|
||||||
$ol_layers['ESRI'] = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}';
|
$dbdsn = "mysql:host=localhost;port=3307;dbname=__DB_USER__;charset=utf8";
|
||||||
$ol_layers['UMP'] = 'http://{1-3}.tiles.ump.waw.pl/ump_tiles/{z}/{x}/{y}.png';
|
|
||||||
$ol_layers['Osmapa.pl'] = 'http://{a-c}.tile.openstreetmap.pl/osmapa.pl/{z}/{x}/{y}.png';
|
// Database user name
|
||||||
// default coordinates for initial map
|
$dbuser = "__DB_USER__";
|
||||||
$init_latitude = 52.23;
|
|
||||||
$init_longitude = 21.01;
|
// Database user password
|
||||||
// you may set your google maps api key
|
$dbpass = "__DB_PWD__";
|
||||||
$gkey = "";
|
|
||||||
// MySQL config
|
// Optional table names prefix, eg. "ulogger_"
|
||||||
$dbhost = "localhost"; // mysql host, eg. localhost
|
$dbprefix = "";
|
||||||
$dbuser = "__dbuser__"; // database user
|
|
||||||
$dbpass = "__dbpass__"; // database pass
|
|
||||||
$dbname = "__dbuser__"; // database name
|
|
||||||
$dbprefix = ""; // optional table names prefix, eg. "ulogger_"
|
|
||||||
// other
|
|
||||||
// require login/password authentication
|
|
||||||
// (0 = no, 1 = yes)
|
|
||||||
$require_authentication = 1;
|
|
||||||
// all users tracks are visible to authenticated user
|
|
||||||
// (0 = no, 1 = yes)
|
|
||||||
$public_tracks = 0;
|
|
||||||
// admin user, who
|
|
||||||
// - can add new users
|
|
||||||
// - can edit all tracks, users
|
|
||||||
// - has access to all users locations
|
|
||||||
// none if empty
|
|
||||||
$admin_user = "__admin__";
|
|
||||||
// miniumum required length of user password
|
|
||||||
$pass_lenmin = 12;
|
|
||||||
// required strength of user password
|
|
||||||
// 0 = no requirements,
|
|
||||||
// 1 = require mixed case letters (lower and upper),
|
|
||||||
// 2 = require mixed case and numbers,
|
|
||||||
// 3 = require mixed case, numbers and non-alphanumeric characters
|
|
||||||
$pass_strength = 2;
|
|
||||||
// Default interval in seconds for live auto reload
|
|
||||||
$interval = 10;
|
|
||||||
// Default language
|
|
||||||
// (en, pl, de, hu)
|
|
||||||
$lang = "__lang__";
|
|
||||||
//$lang = "pl";
|
|
||||||
//$lang = "de";
|
|
||||||
//$lang = "hu";
|
|
||||||
//$lang = "fr";
|
|
||||||
//$lang = "it";
|
|
||||||
// units
|
|
||||||
// (metric, imperial)
|
|
||||||
$units = "metric";
|
|
||||||
//$units = "imperial";
|
|
||||||
//$units = "nautical";
|
|
||||||
// These need to be copied to config.php
|
|
||||||
$strokeWeight = 2;
|
|
||||||
$strokeColor = '#FF0000';
|
|
||||||
$strokeOpacity = 1.0;
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -16,7 +16,7 @@ location __PATH__/ {
|
||||||
try_files $uri $uri/ index.php;
|
try_files $uri $uri/ index.php;
|
||||||
location ~ [^/]\.php(/|$) {
|
location ~ [^/]\.php(/|$) {
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
|
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_param REMOTE_USER $remote_user;
|
fastcgi_param REMOTE_USER $remote_user;
|
||||||
|
|
|
@ -33,7 +33,7 @@ group = __USER__
|
||||||
; (IPv6 and IPv4-mapped) on a specific port;
|
; (IPv6 and IPv4-mapped) on a specific port;
|
||||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||||
; Note: This value is mandatory.
|
; Note: This value is mandatory.
|
||||||
listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock
|
listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
|
||||||
|
|
||||||
; Set listen(2) backlog.
|
; Set listen(2) backlog.
|
||||||
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Real-time collection of geolocation data, tracks viewing and management.",
|
"en": "Real-time collection of geolocation data, tracks viewing and management.",
|
||||||
"fr": "Géolocalisation en temps réel, gestion et affichage de traces."
|
"fr": "Géolocalisation en temps réel, gestion et affichage de traces."
|
||||||
},
|
},
|
||||||
"version": "0.5~ynh2",
|
"version": "1.0~ynh1",
|
||||||
"url": "https://github.com/bfabiszewski/ulogger-server",
|
"url": "https://github.com/bfabiszewski/ulogger-server",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -14,12 +14,12 @@
|
||||||
"email": "anmol@datamol.org"
|
"email": "anmol@datamol.org"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.8.1"
|
"yunohost": ">= 4.0.0"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"php7.0-fpm",
|
"php7.3-fpm",
|
||||||
"mysql"
|
"mysql"
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
|
|
BIN
screenshot.png
Normal file
BIN
screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
|
@ -1,5 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# COMMON VARIABLES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
YNH_PHP_VERSION="7.3"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PERSONAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# FUTURE OFFICIAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Send an email to inform the administrator
|
# Send an email to inform the administrator
|
||||||
#
|
#
|
||||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||||
|
|
|
@ -28,9 +28,10 @@ ynh_print_info --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
@ -53,7 +54,7 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
# BACKUP THE PHP-FPM CONFIGURATION
|
# BACKUP THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
|
ynh_backup "/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE MYSQL DATABASE
|
# BACKUP THE MYSQL DATABASE
|
||||||
|
|
|
@ -41,40 +41,38 @@ 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"
|
||||||
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register $app $domain $path_url
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
|
|
||||||
admin_password=$(openssl passwd -1 -salt xyz $password)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..."
|
ynh_script_progression --message="Storing installation settings..."
|
||||||
|
|
||||||
ynh_app_setting_set $app domain $domain
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set $app path $path_url
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
ynh_app_setting_set $app admin $admin
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
ynh_app_setting_set $app is_public $is_public
|
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||||
ynh_app_setting_set $app language $language
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A MYSQL DATABASE
|
# CREATE A MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a MySQL database..."
|
ynh_script_progression --message="Creating a MySQL database..."
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid $app)
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
ynh_app_setting_set $app db_name $db_name
|
db_user=$db_name
|
||||||
ynh_mysql_setup_db $db_name $db_name
|
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||||
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
|
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..."
|
ynh_script_progression --message="Setting up source files..."
|
||||||
|
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$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 --dest_dir="$final_path"
|
||||||
#Copy config.php to the final path
|
|
||||||
cp -r ../conf/config.php $final_path
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -99,34 +97,38 @@ ynh_script_progression --message="Configuring PHP-FPM..."
|
||||||
|
|
||||||
# Create a dedicated php-fpm config
|
# Create a dedicated php-fpm config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config
|
||||||
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set right permissions for curl install
|
# Set right permissions for cURL install
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_replace_string "__dbuser__" "$db_name" "$final_path/config.php"
|
cp "../conf/config.php" "$final_path/config.php"
|
||||||
ynh_replace_string "__dbpass__" "$db_pwd" "$final_path/config.php"
|
|
||||||
ynh_replace_string "__admin__" "$admin" "$final_path/config.php"
|
|
||||||
ynh_replace_string "__lang__" "$language" "$final_path/config.php"
|
|
||||||
ynh_replace_string "^\$enabled = false;" "\$enabled = true;" "$final_path/scripts/setup.php"
|
|
||||||
# Replace variables in sql scripts
|
|
||||||
ynh_replace_string "__admin__" "$admin" ../conf/admin.sql
|
|
||||||
ynh_replace_string "__admin_pwd__" "$admin_password" ../conf/admin.sql
|
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/config.php"
|
||||||
|
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$final_path/config.php"
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="\$enabled = false;" --replace_string="\$enabled = true;" --target_file="$final_path/scripts/setup.php"
|
||||||
|
|
||||||
|
admin_pwd=$(openssl passwd -1 -salt xyz $password)
|
||||||
|
|
||||||
|
# Replace variables in SQL scripts
|
||||||
|
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="../conf/admin.sql"
|
||||||
|
ynh_replace_string --match_string="__ADMIN_PWD__" --replace_string="$admin_pwd" --target_file="../conf/admin.sql"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP APPLICATION WITH CURL
|
# SETUP APPLICATION WITH CURL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set the app as temporarily public for cURL call
|
# Set the app as temporarily public for cURL call
|
||||||
ynh_permission_update --permission "main" --add "visitors"
|
ynh_permission_update --permission="main" --add="visitors"
|
||||||
|
|
||||||
# Reload NGINX
|
# Reload NGINX
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
@ -164,7 +166,7 @@ ynh_script_progression --message="Configuring permissions..."
|
||||||
# Make app public if necessary or protect it
|
# Make app public if necessary or protect it
|
||||||
if [ $is_public -eq 0 ]
|
if [ $is_public -eq 0 ]
|
||||||
then
|
then
|
||||||
ynh_permission_update --permission "main" --remove "visitors"
|
ynh_permission_update --permission="main" --remove="visitors"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -16,10 +16,10 @@ ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE MYSQL DATABASE
|
# REMOVE THE MYSQL DATABASE
|
||||||
|
@ -27,7 +27,7 @@ final_path=$(ynh_app_setting_get $app final_path)
|
||||||
ynh_script_progression --message="Removing the MySQL database"
|
ynh_script_progression --message="Removing the MySQL database"
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_mysql_remove_db $db_user $db_name
|
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
|
@ -35,7 +35,7 @@ ynh_mysql_remove_db $db_user $db_name
|
||||||
ynh_script_progression --message="Removing app main directory"
|
ynh_script_progression --message="Removing app main directory"
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove "$final_path"
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
|
@ -61,7 +61,7 @@ ynh_remove_fpm_config
|
||||||
ynh_script_progression --message="Removing the dedicated system user"
|
ynh_script_progression --message="Removing the dedicated system user"
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete $app
|
ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -27,10 +27,12 @@ ynh_script_progression --message="Loading settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get $app path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
|
db_user=$db_name
|
||||||
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
@ -55,7 +57,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..."
|
ynh_script_progression --message="Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
|
@ -63,22 +65,22 @@ ynh_restore_file "$final_path"
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create $app
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the MySQL database..."
|
ynh_script_progression --message="Restoring the MySQL database..."
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
|
ynh_restore_file "/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
@ -87,7 +89,7 @@ ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
|
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=php7.0-fpm --action=reload
|
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -16,12 +16,19 @@ ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get $app path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
admin=$(ynh_app_setting_get $app admin)
|
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK VERSION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
@ -49,6 +56,13 @@ if [ -z $final_path ]; then
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Cleaning legacy permissions
|
||||||
|
if ynh_legacy_permissions_exists; then
|
||||||
|
ynh_legacy_permissions_delete_all
|
||||||
|
|
||||||
|
ynh_app_setting_delete --app=$app --key=is_public
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -69,36 +83,28 @@ ynh_abort_if_errors
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
|
|
||||||
# Create a temporary directory
|
# Create a temporary directory
|
||||||
tmpdir="$(ynh_smart_mktemp 300)"
|
tmpdir="$(mktemp -d)"
|
||||||
|
|
||||||
# Backup the config file in the temp dir
|
# Backup the config file in the temp dir
|
||||||
cp -a "$final_path/config.php" "$tmpdir/config.php"
|
cp -a "$final_path/config.php" "$tmpdir/config.php"
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove "$final_path"
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading source files..."
|
|
||||||
|
|
||||||
# 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 --dest_dir="$final_path"
|
||||||
|
|
||||||
|
|
||||||
#copy cofig.php from tmp to final_path
|
#copy cofig.php from tmp to final_path
|
||||||
cp -a "$tmpdir/config.php" "${final_path}"
|
cp -a "$tmpdir/config.php" "$final_path/config.php"
|
||||||
|
|
||||||
#remove tmp dir
|
# Remove the tmp directory securely
|
||||||
ynh_secure_remove "$tmpdir"
|
ynh_secure_remove --file="$tmpdir"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -129,6 +135,7 @@ ynh_add_fpm_config
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different "$final_path/conf.php"
|
ynh_backup_if_checksum_is_different "$final_path/conf.php"
|
||||||
|
|
||||||
# Recalculate and store the config file checksum into the app settings
|
# Recalculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum "$final_path/config.php"
|
ynh_store_file_checksum "$final_path/config.php"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue