1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/20euros_ynh.git synced 2024-09-03 18:05:53 +02:00

repackage

This commit is contained in:
ericgaspar 2020-05-10 10:40:23 +02:00
parent ca337bca00
commit b5dc19d5d9
No known key found for this signature in database
GPG key ID: 574F281483054D44
9 changed files with 264 additions and 66 deletions

6
conf/app.src Normal file
View file

@ -0,0 +1,6 @@
SOURCE_URL=https://github.com/jatekos101/20euros/archive/v0.1.tar.gz
SOURCE_SUM=a119aaf8130756616e79bad040a1fe3db4b1f9b5a09b37a8eb0f2b4a04e3cca5
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=20euros-0.1.tar.gz

View file

@ -1,13 +1,14 @@
location YNH_WWW_PATH { #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
alias YNH_WWW_ALIAS ; location __PATH__/ {
# Force https # Path to source
alias __FINALPATH__/ ;
# Force usage of https
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
index index.html;
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -1,19 +1,30 @@
{ {
"name": "20euros", "name": "20euros",
"id": "20euros", "id": "20euros",
"packaging_format": 1,
"description": { "description": {
"en": "2048 - 20euros", "en": "2048 - 20euros",
"fr": "2048 - 20euros" "fr": "2048 - 20euros"
}, },
"version": "1.0~ynh1",
"url": "https://github.com/jatekos101/20euros",
"license": "MIT",
"developer": { "developer": {
"name": "Moul", "name": "Moul",
"email": "moul@moul.re" "email": "moul@moul.re"
}, },
"multi_instance": "false", "requirements": {
"yunohost": ">= 3.7.0"
},
"multi_instance": true,
"services": [
"nginx"
],
"arguments": { "arguments": {
"install" : [ "install" : [
{ {
"name": "domain", "name": "domain",
"type": "domain",
"ask": { "ask": {
"en": "Choose a domain for 20euros", "en": "Choose a domain for 20euros",
"fr": "Choisissez un nom de domaine pour 20euros" "fr": "Choisissez un nom de domaine pour 20euros"
@ -22,6 +33,7 @@
}, },
{ {
"name": "path", "name": "path",
"type": "path",
"ask": { "ask": {
"en": "Choose a path for 20euros", "en": "Choose a path for 20euros",
"fr": "Choisissez un chemin pour 20euros" "fr": "Choisissez un chemin pour 20euros"
@ -31,12 +43,16 @@
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean",
"ask": { "ask": {
"en": "Is it a public game?", "en": "Is it a public game?",
"fr": "Est-ce un jeu public ?" "fr": "Est-ce un jeu public ?"
}, },
"choices": ["Yes", "No"], "help": {
"default": "Yes" "en": "If enabled, 20euros will be accessible by people who doesnt have an account. This can be changed later via the webadmin.",
"fr": "Si cette case est cochée, 20euros sera accessible aux personnes nayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."
},
"default": true
} }
] ]
} }

0
scripts/backup Normal file
View file

0
scripts/change_url Normal file
View file

View file

@ -1,41 +1,98 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
# Retrieve arguments # Retrieve arguments
domain=$1
path=$2
is_public=$3
# Check domain/path availability domain=$YNH_APP_ARG_DOMAIN
sudo yunohost app checkurl $domain$path -a 20euros path_url=$YNH_APP_ARG_PATH
if [[ ! $? -eq 0 ]]; then is_public=$YNH_APP_ARG_IS_PUBLIC
exit 1
fi
app=$YNH_APP_INSTANCE_NAME
# Save app settings #=================================================
sudo yunohost app setting 20euros is_public -v "$is_public" # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
# Copy files to the right place # Copy files to the right place
final_path=/var/www/20euros final_path=/var/www/$app
sudo mkdir -p $final_path test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
sudo cp -a ../sources/* $final_path
# Set permissions # Register (book) web path
sudo chown -R www-data: $final_path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
# Modify Nginx configuration file and copy it to Nginx conf directory #=================================================
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf # STORE SETTINGS FROM MANIFEST
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf #=================================================
nginxconf=/etc/nginx/conf.d/$domain.d/20euros.conf ynh_script_progression --message="Storing installation settings..." --weight=2
sudo cp ../conf/nginx.conf $nginxconf
sudo chown root: $nginxconf
sudo chmod 600 $nginxconf
if [ "$is_public" = "Yes" ]; ynh_app_setting_set --app=$app --key=domain --value=$domain
then ynh_app_setting_set --app=$app --key=path --value=$path_url
sudo yunohost app setting 20euros skipped_uris -v "/" ynh_app_setting_set --app=$app --key=is_public --value=$is_public
fi
# Reload web server & sso #=================================================
sudo service nginx reload # STANDARD MODIFICATIONS
sudo yunohost app ssowatconf #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
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..." --weight=2
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R root: $final_path
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..." --weight=1
# Make app public if necessary or protect it
[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading Nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -1,6 +1,43 @@
#!/bin/bash #!/bin/bash
domain=$(sudo yunohost app setting 20euros domain) #=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
sudo rm -rf /var/www/20euros source /usr/share/yunohost/helpers
sudo rm -f /etc/nginx/conf.d/$domain.d/20euros.conf
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=3
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing Nginx web server configuration..." --weight=1
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

0
scripts/restore Normal file
View file

View file

@ -1,34 +1,115 @@
#!/bin/bash #!/bin/bash
# Retrieve settings #=================================================
domain=$(sudo yunohost app setting 20euros domain) # GENERIC START
path=$(sudo yunohost app setting 20euros path) #=================================================
is_public=$(sudo yunohost app setting 20euros is_public) # IMPORT GENERIC HELPERS
#=================================================
# Remove trailing "/" for next commands source /usr/share/yunohost/helpers
path=${path%/}
# Copy files to the right place #=================================================
final_path=/var/www/20euros # LOAD SETTINGS
sudo mkdir -p $final_path #=================================================
sudo cp -a ../sources/* $final_path ynh_script_progression --message="Loading installation settings..." --weight=1
# Set permissions app=$YNH_APP_INSTANCE_NAME
sudo chown -R www-data: $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory domain=$(ynh_app_setting_get --app=$app --key=domain)
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf path_url=$(ynh_app_setting_get --app=$app --key=path)
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf is_public=$(ynh_app_setting_get --app=$app --key=is_public)
nginxconf=/etc/nginx/conf.d/$domain.d/20euros.conf final_path=$(ynh_app_setting_get --app=$app --key=final_path)
sudo cp ../conf/nginx.conf $nginxconf
sudo chown root: $nginxconf
sudo chmod 600 $nginxconf
if [ "$is_public" = "Yes" ]; #=================================================
then # CHECK VERSION
sudo yunohost app setting 20euros skipped_uris -v "/" #=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
fi fi
# Reload web server & sso # If final_path doesn't exist, create it
sudo service nginx reload if [ -z "$final_path" ]; then
sudo yunohost app ssowatconf final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
# 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
#=================================================
path_url=$(ynh_normalize_url_path --path_url=$path_url)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=4
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chown -R root: $final_path
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1
# Make app public if necessary or protect it
[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last