diff --git a/README.md b/README.md index 1653358..fe3e581 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,11 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## 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. -**Version:** 0.5 +**Version:** 1.0 + +## Screenshots + +![](screenshot.png) ## Demo * [Official demo](http://ulogger.fabiszewski.net/) (login: demo, password: demo) diff --git a/check_process b/check_process index 0860708..fde3dea 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,6 @@ # See here for more informations # 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) diff --git a/conf/admin.sql b/conf/admin.sql index 5bd4d45..8a0cdb7 100644 --- a/conf/admin.sql +++ b/conf/admin.sql @@ -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__'); + \ No newline at end of file diff --git a/conf/app.src b/conf/app.src index d27a5a0..e254634 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/bfabiszewski/ulogger-server/archive/v0.5.zip -SOURCE_SUM=77205e03323ab7aab46f2115e578357dd65b1ba8476d9d348ae3dc216f58a4d3 +SOURCE_URL=https://github.com/bfabiszewski/ulogger-server/archive/v1.0.zip +SOURCE_SUM=aac2f69f64477b3a1c4265d19603fa32d9ba385f3e00358c0a4f08e7dcbb2020 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=true diff --git a/conf/config.php b/conf/config.php index 149387b..2aa6296 100755 --- a/conf/config.php +++ b/conf/config.php @@ -16,68 +16,26 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ + // This is default configuration file. // Copy it to config.php and customize -// default map drawing framework -//$mapapi = "gmaps"; // google maps -//$mapapi = "openlayers"; // openlayers 2 -$mapapi = "openlayers3"; // openlayers 3+ -// openlayers additional map layers in XYZ format -// name => url -$ol_layers['OpenCycleMap'] = 'https://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png'; // ?apikey=[API_KEY] -$ol_layers['OpenTopoMap'] = 'https://{a-c}.tile.opentopomap.org/{z}/{x}/{y}.png'; -$ol_layers['ESRI'] = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'; -$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'; -// default coordinates for initial map -$init_latitude = 52.23; -$init_longitude = 21.01; -// you may set your google maps api key -$gkey = ""; -// MySQL config -$dbhost = "localhost"; // mysql host, eg. localhost -$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; + +// Database config + +// PDO data source name, eg.: +// mysql:host=localhost;port=3307;dbname=ulogger;charset=utf8 +// mysql:unix_socket=/tmp/mysql.sock;dbname=ulogger;charset=utf8 +// pgsql:host=localhost;port=5432;dbname=ulogger +// sqlite:/tmp/ulogger.db +$dbdsn = "mysql:host=localhost;port=3307;dbname=__DB_USER__;charset=utf8"; + +// Database user name +$dbuser = "__DB_USER__"; + +// Database user password +$dbpass = "__DB_PWD__"; + +// Optional table names prefix, eg. "ulogger_" +$dbprefix = ""; + ?> diff --git a/conf/nginx.conf b/conf/nginx.conf index f220fda..2b2538e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -16,7 +16,7 @@ location __PATH__/ { try_files $uri $uri/ index.php; location ~ [^/]\.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; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index ab5dca9..ab1a471 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -33,7 +33,7 @@ group = __USER__ ; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; 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. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) diff --git a/manifest.json b/manifest.json index 645149c..74dacda 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Real-time collection of geolocation data, tracks viewing and management.", "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", "license": "AGPL-3.0-only", "maintainer": { @@ -14,12 +14,12 @@ "email": "anmol@datamol.org" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.0.0" }, "multi_instance": true, "services": [ "nginx", - "php7.0-fpm", + "php7.3-fpm", "mysql" ], "arguments": { diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..4bb2639 Binary files /dev/null and b/screenshot.png differ diff --git a/scripts/_common.sh b/scripts/_common.sh index 9e3b7ca..cbb04d3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,23 @@ #!/bin/bash +#================================================= +# COMMON VARIABLES +#================================================= + +YNH_PHP_VERSION="7.3" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= + # Send an email to inform the administrator # # usage: ynh_send_readme_to_admin app_message [recipients] diff --git a/scripts/backup b/scripts/backup index 7f9fee5..1fad65a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -28,9 +28,10 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +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 @@ -53,7 +54,7 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # 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 diff --git a/scripts/install b/scripts/install index dc5fe1e..4580bc5 100644 --- a/scripts/install +++ b/scripts/install @@ -41,40 +41,38 @@ final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" # Register (book) web path -ynh_webpath_register $app $domain $path_url - -admin_password=$(openssl passwd -1 -salt xyz $password) +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin -ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app language $language +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=admin --value=$admin +ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=language --value=$language #================================================= # CREATE A MYSQL DATABASE #================================================= ynh_script_progression --message="Creating a MySQL database..." -db_name=$(ynh_sanitize_dbid $app) -ynh_app_setting_set $app db_name $db_name -ynh_mysql_setup_db $db_name $db_name +db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$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 #================================================= 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 -ynh_setup_source "$final_path" -#Copy config.php to the final path -cp -r ../conf/config.php $final_path +ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION @@ -99,34 +97,38 @@ ynh_script_progression --message="Configuring PHP-FPM..." # Create a dedicated php-fpm config ynh_add_fpm_config +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SPECIFIC SETUP #================================================= -# Set right permissions for curl install +# Set right permissions for cURL install chown -R $app: $final_path #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_replace_string "__dbuser__" "$db_name" "$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 +cp "../conf/config.php" "$final_path/config.php" +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 #================================================= # 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 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 if [ $is_public -eq 0 ] then - ynh_permission_update --permission "main" --remove "visitors" + ynh_permission_update --permission="main" --remove="visitors" fi #================================================= diff --git a/scripts/remove b/scripts/remove index f0bf565..d382bc1 100644 --- a/scripts/remove +++ b/scripts/remove @@ -16,10 +16,10 @@ ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=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 @@ -27,7 +27,7 @@ final_path=$(ynh_app_setting_get $app final_path) ynh_script_progression --message="Removing the MySQL database" # 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 @@ -35,7 +35,7 @@ ynh_mysql_remove_db $db_user $db_name ynh_script_progression --message="Removing app main directory" # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION @@ -61,7 +61,7 @@ ynh_remove_fpm_config ynh_script_progression --message="Removing the dedicated system user" # Delete a system user -ynh_system_user_delete $app +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 4dd5b96..2a4c50b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,10 +27,12 @@ ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +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 @@ -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_restore_file "$final_path" +ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER @@ -63,22 +65,22 @@ ynh_restore_file "$final_path" ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # RESTORE THE MYSQL DATABASE #================================================= ynh_script_progression --message="Restoring the MySQL database..." -db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_mysql_setup_db $db_name $db_name $db_pwd -ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # 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 @@ -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_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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index ef6c72c..4feed9c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,12 +16,19 @@ ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -admin=$(ynh_app_setting_get $app admin) -is_public=$(ynh_app_setting_get $app is_public) -final_path=$(ynh_app_setting_get $app final_path) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +admin=$(ynh_app_setting_get --app=$app --key=admin) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +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 @@ -49,6 +56,13 @@ if [ -z $final_path ]; then ynh_app_setting_set $app final_path $final_path 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 #================================================= @@ -69,36 +83,28 @@ ynh_abort_if_errors # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -# Download, check integrity, uncompress and patch the source from app.src -# Create a temporary directory -tmpdir="$(ynh_smart_mktemp 300)" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --weight=1 -# Backup the config file in the temp dir -cp -a "$final_path/config.php" "$tmpdir/config.php" + # Create a temporary directory + tmpdir="$(mktemp -d)" -# Remove the app directory securely -ynh_secure_remove "$final_path" + # Backup the config file in the temp dir + cp -a "$final_path/config.php" "$tmpdir/config.php" -# 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 + # Remove the app directory securely + ynh_secure_remove --file="$final_path" -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Upgrading source files..." + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" + #copy cofig.php from tmp to final_path + cp -a "$tmpdir/config.php" "$final_path/config.php" - -#copy cofig.php from tmp to final_path -cp -a "$tmpdir/config.php" "${final_path}" - -#remove tmp dir -ynh_secure_remove "$tmpdir" + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" +fi #================================================= # NGINX CONFIGURATION @@ -129,6 +135,7 @@ ynh_add_fpm_config #================================================= ynh_backup_if_checksum_is_different "$final_path/conf.php" + # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/config.php"