1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ulogger_ynh.git synced 2024-10-01 13:34:45 +02:00

Merge pull request #20 from YunoHost-Apps/testing

Testing
This commit is contained in:
Éric Gaspar 2022-08-09 07:10:07 +02:00 committed by GitHub
commit bed3a97975
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 80 additions and 173 deletions

View file

@ -17,8 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
**μlogger** 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 serverclient solution for logging and monitoring users' geolocation.
Together with a dedicated [μlogger mobile client](https://github.com/bfabiszewski/ulogger-android) it may be used as a complete self hosted serverclient solution for logging and monitoring users' geolocation.
**Shipped version:** 1.1~ynh1

View file

@ -17,8 +17,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
**μlogger** 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 serverclient solution for logging and monitoring users' geolocation.
Together with a dedicated [μlogger mobile client](https://github.com/bfabiszewski/ulogger-android) it may be used as a complete self hosted serverclient solution for logging and monitoring users' geolocation.
**Version incluse :** 1.1~ynh1

View file

@ -3,11 +3,12 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john"
is_public=1 (PUBLIC|public=1|private=0)
domain="domain.tld"
path="/path"
is_public=1
language="fr"
admin="john"
password="1Strong-Password"
; Checks
pkg_linter=1
setup_sub_dir=1

View file

@ -2,7 +2,7 @@
location __PATH__/ {
# Path to source
alias __FINALPATH__/ ;
alias __FINALPATH__/;
index index.html index.php;

View file

@ -1,4 +1,3 @@
**μlogger** 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 serverclient solution for logging and monitoring users' geolocation.
Together with a dedicated [μlogger mobile client](https://github.com/bfabiszewski/ulogger-android) it may be used as a complete self hosted serverclient solution for logging and monitoring users' geolocation.

View file

@ -39,10 +39,6 @@
"example": "/ulogger",
"default": "/ulogger"
},
{
"name": "admin",
"type": "user"
},
{
"name": "is_public",
"type": "boolean",
@ -59,8 +55,16 @@
"en": "Choose the application language",
"fr": "Choisissez la langue de l'application"
},
"choices": ["fr", "en", "pl", "de", "hu", "it" ],
"choices": ["de", "en", "fr", "hu", "it", "pl"],
"default": "en"
},
{
"name": "admin",
"type": "user"
},
{
"name": "password",
"type": "password"
}
]
}

View file

@ -6,6 +6,8 @@
YNH_PHP_VERSION="7.3"
pkg_dependencies="php${YNH_PHP_VERSION}-mysql"
#=================================================
# PERSONAL HELPERS
#=================================================
@ -17,86 +19,3 @@ YNH_PHP_VERSION="7.3"
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin app_message [recipients]
# | arg: app_message - The message to send to the administrator.
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
# example: "root admin@domain"
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
# example: "root admin@domain user1 user2"
ynh_send_readme_to_admin() {
local app_message="${1:-...No specific information...}"
local recipients="${2:-root}"
# Retrieve the email of users
find_mails () {
local list_mails="$1"
local mail
local recipients=" "
# Read each mail in argument
for mail in $list_mails
do
# Keep root or a real email address as it is
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
then
recipients="$recipients $mail"
else
# But replace an user name without a domain after by its email
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
then
recipients="$recipients $mail"
fi
fi
done
echo "$recipients"
}
recipients=$(find_mails "$recipients")
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` has important message for you"
local mail_message="This is an automated message from your beloved YunoHost server.
Specific information for the application $app.
$app_message
---
Automatic diagnosis data from YunoHost
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
# Define binary to use for mail command
if [ -e /usr/bin/bsd-mailx ]
then
local mail_bin=/usr/bin/bsd-mailx
else
local mail_bin=/usr/bin/mail.mailutils
fi
# Send the email to the recipients
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
}
ynh_smart_mktemp () {
local min_size="${1:-300}"
# Transform the minimum size from megabytes to kilobytes
min_size=$(( $min_size * 1024 ))
# Check if there's enough free space in a directory
is_there_enough_space () {
local free_space=$(df --output=avail "$1" | sed 1d)
test $free_space -ge $min_size
}
if is_there_enough_space /tmp; then
local tmpdir=/tmp
elif is_there_enough_space /var; then
local tmpdir=/var
elif is_there_enough_space /; then
local tmpdir=/
elif is_there_enough_space /home; then
local tmpdir=/home
else
ynh_die "Insufficient free space to continue..."
fi
echo "$(mktemp --directory --tmpdir="$tmpdir")"
}

View file

@ -28,7 +28,8 @@ path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE
password=$(ynh_string_random 12)
password=$YNH_APP_ARG_PASSWORD
admin_pwd=$(openssl passwd -1 -salt xyz $password)
app=$YNH_APP_INSTANCE_NAME
@ -53,6 +54,13 @@ 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=language --value=$language
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -80,14 +88,6 @@ 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 --dest_dir="$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
@ -97,6 +97,14 @@ ynh_script_progression --message="Configuring PHP-FPM..."
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
@ -107,17 +115,15 @@ chown -R $app: $final_path
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
cp "../conf/config.php" "$final_path/config.php"
ynh_add_config --template="../conf/config.php" --destination="$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="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config.php"
chmod 400 "$final_path/config.php"
chown $app:$app "$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"
@ -126,6 +132,7 @@ ynh_replace_string --match_string="__ADMIN_PWD__" --replace_string="$admin_pwd"
# SETUP APPLICATION WITH CURL
#=================================================
ynh_script_progression --message="Configuring SSOwat..."
# Set the app as temporarily public for cURL call
ynh_permission_update --permission="main" --add="visitors"
@ -137,9 +144,9 @@ ynh_script_progression --message="Finalizing installation..."
ynh_local_curl "/scripts/setup.php" "command=setup"
#Add the admin account to the database
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "../conf/admin.sql"
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name < "../conf/admin.sql"
#Disable setup for security
ynh_replace_string "^\$enabled = true;" "\$enabled = false;" "$final_path/scripts/setup.php"
ynh_replace_string --match_string="^\$enabled = true;" --replace_string="\$enabled = false;" --target_file="$final_path/scripts/setup.php"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
@ -155,8 +162,6 @@ ynh_store_file_checksum "$final_path/config.php"
#=================================================
# Set permissions to app files
chown -R $app: $final_path
chmod 755 -R $final_path
chmod -R o-rwx $final_path
chown -R $app:www-data $final_path
@ -169,6 +174,8 @@ ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary or protect it
if [ $is_public -eq 0 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --remove="visitors"
fi
@ -179,21 +186,6 @@ ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
message=" $app was successfully installed :)
Please open your $app domain: https://$domain$path_url
The admin username is: $admin
The admin password is: $password
If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/ulogger_ynh/issues"
ynh_send_readme_to_admin "$message"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -53,6 +53,14 @@ ynh_script_progression --message="Removing PHP-FPM configuration"
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -64,13 +64,12 @@ chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# RESTORE THE MYSQL DATABASE
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Restoring the MySQL database..."
ynh_script_progression --message="Reinstalling dependencies..."
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
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
@ -86,6 +85,15 @@ ynh_script_progression --message="Restoring the NGINX web server configuration..
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..."
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
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -85,31 +85,27 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Create a temporary directory
tmpdir="$(mktemp -d)"
# Backup the config file in the temp dir
cp -a "$final_path/config.php" "$tmpdir/config.php"
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
#copy cofig.php from tmp to final_path
cp -a "$tmpdir/config.php" "$final_path/config.php"
# Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir"
ynh_setup_source --dest_dir="$final_path" --keep="$final_path/config.php"
fi
chmod 755 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
# Create a dedicated php-fpm config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#=================================================
@ -120,24 +116,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
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"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set right permissions for curl installation
chown -R $app: $final_path
#=================================================
# RELOAD NGINX
#=================================================