initial commit
This commit is contained in:
parent
dd377da623
commit
7d197c8959
4 changed files with 56 additions and 118 deletions
|
@ -1,13 +1,15 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Small description of the service
|
Description=Garage Data Store
|
||||||
After=network.target
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Environment='RUST_LOG=garage=info' 'RUST_BACKTRACE=1'
|
||||||
User=__APP__
|
ExecStart=__FINALPATH__/garage server
|
||||||
Group=__APP__
|
StateDirectory=garage
|
||||||
WorkingDirectory=__FINALPATH__/
|
DynamicUser=true
|
||||||
ExecStart=__FINALPATH__/script
|
ProtectHome=true
|
||||||
|
NoNewPrivileges=true
|
||||||
StandardOutput=append:/var/log/__APP__/__APP__.log
|
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
||||||
|
@ -15,7 +17,6 @@ StandardError=inherit
|
||||||
# Depending on specificities of your service/app, you may need to tweak these
|
# Depending on specificities of your service/app, you may need to tweak these
|
||||||
# .. but this should be a good baseline
|
# .. but this should be a good baseline
|
||||||
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
||||||
NoNewPrivileges=yes
|
|
||||||
PrivateTmp=yes
|
PrivateTmp=yes
|
||||||
PrivateDevices=yes
|
PrivateDevices=yes
|
||||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||||
|
|
|
@ -1,73 +1,34 @@
|
||||||
{
|
{
|
||||||
"name": "Example app",
|
"name": "garage_ynh",
|
||||||
"id": "example",
|
"id": "garage",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"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)",
|
"en": "S3 storage",
|
||||||
"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)"
|
"fr": "stockage S3"
|
||||||
},
|
},
|
||||||
"version": "1.0~ynh1",
|
"version": "1.0~ynh1",
|
||||||
"url": "https://example.com",
|
"url": "https://garagehq.deuxfleurs.fr/",
|
||||||
"upstream": {
|
"upstream": {
|
||||||
"license": "free",
|
"license": "free",
|
||||||
"website": "https://example.com",
|
"website": "https://garagehq.deuxfleurs.fr/",
|
||||||
"demo": "https://demo.example.com",
|
"admindoc": "https://garagehq.deuxfleurs.fr/documentation/quick-start/",
|
||||||
"admindoc": "https://yunohost.org/packaging_apps",
|
"userdoc": "https://garagehq.deuxfleurs.fr/documentation/quick-start/",
|
||||||
"userdoc": "https://yunohost.org/apps",
|
"code": "https://git.deuxfleurs.fr/Deuxfleurs/garage"
|
||||||
"code": "https://some.forge.com/example/example"
|
|
||||||
},
|
},
|
||||||
"license": "free",
|
"license": "AGPLv3",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "John doe",
|
"name": "oiseauroch",
|
||||||
"email": "john.doe@example.com"
|
"email": "tobias.ollive@oiseauroch.fr."
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 4.3.0"
|
"yunohost": ">= 4.3.0"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": false,
|
||||||
"services": [
|
|
||||||
"nginx",
|
|
||||||
"php7.3-fpm",
|
|
||||||
"mysql"
|
|
||||||
],
|
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install": [
|
"install": [
|
||||||
{
|
{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "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."
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,43 @@
|
||||||
# COMMON VARIABLES
|
# 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
|
# 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
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -25,11 +25,6 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
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
|
### 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
|
### 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 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"
|
### 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"
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
# Register (book) web path
|
# 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=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
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
|
# 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
|
### - Remove the section "CLOSE A PORT" in the remove script
|
||||||
|
|
||||||
# Find an available port
|
# 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
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
|
|
||||||
# Optional: Expose this port publicly
|
# 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_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
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -121,25 +104,6 @@ ynh_script_progression --message="Configuring system user..." --time --weight=1
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
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
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -163,24 +127,6 @@ chmod 750 "$final_path"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$final_path"
|
||||||
chown -R $app:www-data "$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
|
# NGINX CONFIGURATION
|
||||||
|
|
Loading…
Reference in a new issue