diff --git a/conf/systemd.service b/conf/systemd.service index 7bb448e..0dd716f 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,13 +1,15 @@ [Unit] -Description=Small description of the service -After=network.target +Description=Garage Data Store +After=network-online.target +Wants=network-online.target [Service] -Type=simple -User=__APP__ -Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/script +Environment='RUST_LOG=garage=info' 'RUST_BACKTRACE=1' +ExecStart=__FINALPATH__/garage server +StateDirectory=garage +DynamicUser=true +ProtectHome=true +NoNewPrivileges=true StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit @@ -15,7 +17,6 @@ StandardError=inherit # Depending on specificities of your service/app, you may need to tweak these # .. but this should be a good baseline # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html -NoNewPrivileges=yes PrivateTmp=yes PrivateDevices=yes RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 diff --git a/manifest.json b/manifest.json index 9fdc46e..f716e62 100644 --- a/manifest.json +++ b/manifest.json @@ -1,73 +1,34 @@ { - "name": "Example app", - "id": "example", + "name": "garage_ynh", + "id": "garage", "packaging_format": 1, "description": { - "en": "Explain in *a few (10~15) words* the purpose of the app or what it actually does (it is meant to give a rough idea to users browsing a catalog of 100+ apps)", - "fr": "Expliquez en *quelques* (10~15) mots l'utilité de l'app ou ce qu'elle fait (l'objectif est de donner une idée grossière pour des utilisateurs qui naviguent dans un catalogue de 100+ apps)" + "en": "S3 storage", + "fr": "stockage S3" }, "version": "1.0~ynh1", - "url": "https://example.com", + "url": "https://garagehq.deuxfleurs.fr/", "upstream": { "license": "free", - "website": "https://example.com", - "demo": "https://demo.example.com", - "admindoc": "https://yunohost.org/packaging_apps", - "userdoc": "https://yunohost.org/apps", - "code": "https://some.forge.com/example/example" + "website": "https://garagehq.deuxfleurs.fr/", + "admindoc": "https://garagehq.deuxfleurs.fr/documentation/quick-start/", + "userdoc": "https://garagehq.deuxfleurs.fr/documentation/quick-start/", + "code": "https://git.deuxfleurs.fr/Deuxfleurs/garage" }, - "license": "free", + "license": "AGPLv3", "maintainer": { - "name": "John doe", - "email": "john.doe@example.com" + "name": "oiseauroch", + "email": "tobias.ollive@oiseauroch.fr." }, "requirements": { "yunohost": ">= 4.3.0" }, - "multi_instance": true, - "services": [ - "nginx", - "php7.3-fpm", - "mysql" - ], + "multi_instance": false, "arguments": { "install": [ { "name": "domain", "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/example", - "default": "/example" - }, - { - "name": "is_public", - "type": "boolean", - "default": true - }, - { - "name": "language", - "type": "string", - "ask": { - "en": "Choose the application language", - "fr": "Choisissez la langue de l'application" - }, - "choices": ["fr", "en"], - "default": "fr" - }, - { - "name": "admin", - "type": "user" - }, - { - "name": "password", - "type": "password", - "help": { - "en": "Use the help field to add an information for the admin about this question.", - "fr": "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question." - } } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 7e55ac0..b4be45b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,13 +4,43 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="deb1 deb2 php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2" #================================================= # PERSONAL HELPERS #================================================= + +GARAGE_VERSION="0.7.2.1" + +# inspired by restic helper +install_garage () { + architecture=$(uname -m) + arch='' + case $architecture in + i386|i686) + arch="i686" + ;; + x86_64) + arch=x86_64 + ;; + armv*) + arch=armv6l + ;; + aarch64) + arch=aarch64 + ;; + *) + echo + ynh_die --message="Unsupported architecture \"$architecture\"" + ;; + esac + wget https://garagehq.deuxfleurs.fr/_releases/v$GARAGE_VERSION/$arch-unknown-linux-musl/garage -O "$app" 2>&1 >/dev/null + chmod +x "$app" + else + ynh_die --message="\nDownloaded file does not match expected sha256 sum, aborting" + fi +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index af6ca03..c979962 100755 --- a/scripts/install +++ b/scripts/install @@ -25,11 +25,6 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC -language=$YNH_APP_ARG_LANGUAGE -admin=$YNH_APP_ARG_ADMIN -password=$YNH_APP_ARG_PASSWORD ### If it's a multi-instance app, meaning it can be installed several times independently ### The id of the app as stated in the manifest is available as $YNH_APP_ID @@ -58,7 +53,7 @@ ynh_script_progression --message="Validating installation parameters..." --time ### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". ### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app" -final_path=/var/www/$app +final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path @@ -71,8 +66,6 @@ ynh_script_progression --message="Storing installation settings..." --time --wei 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=language --value=$language -ynh_app_setting_set --app=$app --key=admin --value=$admin #================================================= # STANDARD MODIFICATIONS @@ -87,7 +80,7 @@ ynh_script_progression --message="Finding an available port..." --time --weight= ### - Remove the section "CLOSE A PORT" in the remove script # Find an available port -port=$(ynh_find_port --port=8095) +port=$(ynh_find_port --port=3900) ynh_app_setting_set --app=$app --key=port --value=$port # Optional: Expose this port publicly @@ -103,16 +96,6 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." --time --weight=1 -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - Remove the variable "pkg_dependencies" in _common.sh -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # CREATE DEDICATED USER #================================================= @@ -121,25 +104,6 @@ ynh_script_progression --message="Configuring system user..." --time --weight=1 # Create a system user ynh_system_user_create --username=$app --home_dir="$final_path" -#================================================= -# CREATE A MYSQL DATABASE -#================================================= -ynh_script_progression --message="Creating a MySQL database..." --time --weight=1 - -### Use these lines if you need a database for the application. -### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password. -### The password will be stored as 'mysqlpwd' into the app settings, -### and will be available as $db_pwd -### If you're not using these lines: -### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script -### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script -### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script - -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -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 #================================================= @@ -163,24 +127,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --time --weight=1 - -### `ynh_add_fpm_config` is used to set up a PHP config. -### You can remove it if your app doesn't use PHP. -### `ynh_add_fpm_config` will use the files conf/php-fpm.conf -### If you're not using these lines: -### - You can remove these files in conf/. -### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script -### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script -### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script -### with the reload at the end of the script. -### - And the section "PHP-FPM CONFIGURATION" in the upgrade script - -# Create a dedicated PHP-FPM config -ynh_add_fpm_config #================================================= # NGINX CONFIGURATION