1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/Cubiks-2048_ynh.git synced 2024-09-03 18:25:55 +02:00

repackage

This commit is contained in:
ericgaspar 2020-05-07 17:43:06 +02:00
parent b2eb06341f
commit 01c3132fc8
No known key found for this signature in database
GPG key ID: 574F281483054D44
10 changed files with 442 additions and 67 deletions

View file

@ -2,8 +2,28 @@
[![Integration level](https://dash.yunohost.org/integration/cubiks2048.svg)](https://dash.yunohost.org/appci/app/cubiks2048) ![](https://ci-apps.yunohost.org/ci/badges/cubiks2048.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cubiks2048.maintain.svg)
> *This package allow you to install Cubiks-2048 quickly and simply on a YunoHost server.
If you dont have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
## Overview
A clone of 2048 game in 3D
* [Try the game](https://kshitij-banerjee.github.io/Cubiks-2048/)
* [Repository](https://github.com/Kshitij-Banerjee/Cubiks-2048)
## Screenshots
![](Screenshot-243.jpg)
## Demo
* [Official demo](https://kshitij-banerjee.github.io/Cubiks-2048/)
#### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/cubiks2048%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/cubiks2048/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/cubiks2048%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/cubiks2048/)
## Links
* Report a bug: https://github.com/YunoHost-Apps/cubiks-2048_ynh/issues
* Upstream app repository: https://github.com/Kshitij-Banerjee/Cubiks-2048
* YunoHost website: https://yunohost.org/

31
check_process Normal file
View file

@ -0,0 +1,31 @@
;; Test complet
auto_remove=1
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
is_public="Yes" (PUBLIC|public=Yes|private=No)
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
backup_restore=1
multi_instance=1
incorrect_path=1
port_already_use=0
change_url=1
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
Level 4=0
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0

6
conf/app.src Normal file
View file

@ -0,0 +1,6 @@
SOURCE_URL=https://github.com/Kshitij-Banerjee/Cubiks-2048/archive/master.tar.gz
SOURCE_SUM=8b45de903449a9b47202cc28d9b20091cab9283634cd655d3fb7b8a65aaf2e91
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=Cubiks-2048-master.tar.gz

View file

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

View file

@ -1,19 +1,27 @@
{
"name": "Cubiks-2048",
"id": "cubiks2048",
"packaging_format": 1,
"description": {
"en": "2048 game clone in 3D",
"fr": "Clone du jeu 2048 en 3D"
},
"version": "1.0~ynh1",
"url": "https://github.com/Kshitij-Banerjee/Cubiks-2048/",
"license": "MIT",
"developer": {
"name": "Moul",
"email": "moul@moul.re"
},
"multi_instance": "false",
"multi_instance": true,
"services": [
"nginx"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain for Cubiks-2048",
"fr": "Choisissez un nom de domaine pour Cubiks-2048"
@ -22,6 +30,7 @@
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Cubiks-2048",
"fr": "Choisissez un chemin pour Cubiks-2048"
@ -31,12 +40,16 @@
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public game?",
"fr": "Est-ce un jeu public ?"
},
"choices": ["Yes", "No"],
"default": "Yes"
"help": {
"en": "If enabled, Cubiks-2048 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, Cubiks-2048 sera accessible aux personnes nayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."
},
"default": true
}
]
}

47
scripts/backup Normal file
View file

@ -0,0 +1,47 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Backing up the main app directory..." --weight=1
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Backing up Nginx web server configuration..." --weight=2
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last

View file

@ -1,41 +1,98 @@
#!/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
domain=$1
path=$2
is_public=$3
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a cubiks2048
if [[ ! $? -eq 0 ]]; then
exit 1
fi
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
# Save app settings
sudo yunohost app setting cubiks2048 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
final_path=/var/www/cubiks2048
sudo mkdir -p $final_path
sudo cp -a ../sources/* $final_path
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Set permissions
sudo chown -R www-data: $final_path
# Register (book) web 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
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
nginxconf=/etc/nginx/conf.d/$domain.d/cubiks2048.conf
sudo cp ../conf/nginx.conf $nginxconf
sudo chown root: $nginxconf
sudo chmod 600 $nginxconf
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting cubiks2048 skipped_uris -v "/"
fi
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=is_public --value=$is_public
# Reload web server & sso
sudo service nginx reload
sudo yunohost app ssowatconf
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# 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
domain=$(sudo yunohost app setting cubiks2048 domain)
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
sudo rm -rf /var/www/cubiks2048
sudo rm -f /etc/nginx/conf.d/$domain.d/cubiks2048.conf
source /usr/share/yunohost/helpers
#=================================================
# 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

82
scripts/restore Normal file
View file

@ -0,0 +1,82 @@
#!/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
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_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)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=2
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown -R root: $final_path
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=3
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -1,34 +1,115 @@
#!/bin/bash
# Retrieve settings
domain=$(sudo yunohost app setting cubiks2048 domain)
path=$(sudo yunohost app setting cubiks2048 path)
is_public=$(sudo yunohost app setting cubiks2048 is_public)
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Remove trailing "/" for next commands
path=${path%/}
source /usr/share/yunohost/helpers
# Copy files to the right place
final_path=/var/www/cubiks2048
sudo mkdir -p $final_path
sudo cp -a ../sources/* $final_path
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Set permissions
sudo chown -R www-data: $final_path
app=$YNH_APP_INSTANCE_NAME
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
nginxconf=/etc/nginx/conf.d/$domain.d/cubiks2048.conf
sudo cp ../conf/nginx.conf $nginxconf
sudo chown root: $nginxconf
sudo chmod 600 $nginxconf
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting cubiks2048 skipped_uris -v "/"
#=================================================
# CHECK VERSION
#=================================================
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
# Reload web server & sso
sudo service nginx reload
sudo yunohost app ssowatconf
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
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