1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/octoprint_ynh.git synced 2024-09-03 19:46:26 +02:00

Automated packaging v2 conversion

This commit is contained in:
Salamandar 2024-06-06 12:02:15 +02:00
parent 4a7145bab8
commit 3747d497dc
7 changed files with 109 additions and 59 deletions

50
manifest.toml Normal file
View file

@ -0,0 +1,50 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "octoprint"
name = "Octoprint"
description.en = "3D printing webserver"
description.fr = "Serveur d'impression 3D"
version = "1.0.0"
maintainers = ["Tropicao"]
[upstream]
license = "Apache-2.0"
website = "https://github.com/Tropicao/octoprint_ynh"
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
[integration]
yunohost = ">= 3.1"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
multi_instance = false
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain"
[install.init_main_permission]
help.en = "If public, your 3D printer will be accessible by anyone on internet"
help.fr = "Dans ce cas, n'importe qui sur internet pourra utiliser votre imprimante"
type = "group"
default = false
[resources]
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.ports]
main.default = 5000

View file

@ -316,7 +316,7 @@ ynh_check_starting () {
}
# Clean temporary process and file used by ynh_check_starting
# (usually used in ynh_clean_setup scripts)
#REMOVEME? # (usually used in ynh_clean_setup scripts)
#
# usage: ynh_clean_check_starting
ynh_clean_check_starting () {

View file

@ -6,18 +6,18 @@
source /usr/share/yunohost/helpers
# manage script failure
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
# retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get "$app" domain)
# definie useful vars
final_path="/opt/yunohost/$app"
#REMOVEME? install_dir="/opt/yunohost/$app"
home_path="/home/$app"
# backup source & conf files
ynh_backup "$final_path"
ynh_backup "$install_dir"
ynh_backup "$home_path"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/sudoers.d/$app"

View file

@ -4,50 +4,50 @@ source _common.sh
source /usr/share/yunohost/helpers
# manage script failure
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
# retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
is_public=$YNH_APP_ARG_IS_PUBLIC
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
# definie useful vars
final_path="/opt/yunohost/$app"
#REMOVEME? install_dir="/opt/yunohost/$app"
home_path="/home/$app"
data_path="/home/$app/.$app"
# check domain/path availability
ynh_script_progression --message="Validating installation parameters..."
path_url=$(ynh_normalize_url_path "/")
ynh_webpath_available "$domain" "$path_url" || ynh_die "$domain/$path_url is not available, please use an other domain."
ynh_webpath_register $app "$domain" "$path_url"
#REMOVEME? ynh_script_progression --message="Validating installation parameters..."
path=$(ynh_normalize_url_path "/")
#REMOVEME? ynh_webpath_available "$domain" "$path" || ynh_die "$domain/$path is not available, please use an other domain."
#REMOVEME? ynh_webpath_register $app "$domain" "$path"
# add required packages
ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
#REMOVEME? ynh_script_progression --message="Installing dependencies..."
#REMOVEME? ynh_install_app_dependencies "$PKG_DEPENDENCIES"
# save app settings
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set $app domain "$domain"
ynh_app_setting_set $app is_public $is_public
#REMOVEME? ynh_script_progression --message="Storing installation settings..."
#REMOVEME? ynh_app_setting_set $app domain "$domain"
#REMOVEME? ynh_app_setting_set $app is_public $is_public
# find a free port & open it
ynh_script_progression --message="Looking for a free port and opening it..."
port=$(ynh_find_port 5000)
ynh_app_setting_set $app port $port
#REMOVEME? port=$(ynh_find_port 5000)
#REMOVEME? ynh_app_setting_set $app port $port
ynh_exec_fully_quiet yunohost firewall allow TCP $port
# create a dedicated system user
ynh_script_progression --message="Creating dedicated user, rights and folders..."
ynh_system_user_create $app
#REMOVEME? ynh_system_user_create $app
# add user to group dialout to allow ttyUSB usage
usermod -a -G dialout $app
## grant sudo permissions to the user to manage his own systemd service
myynh_create_dir "/etc/sudoers.d"
cp "../conf/sudoers" "/etc/sudoers.d/$app"
## create a directory for the installation of Octoprint
myynh_create_dir "$final_path"
chown $app: "$final_path"
myynh_create_dir "$install_dir"
chown $app: "$install_dir"
## create a directory for the datas of Octoprint
myynh_create_dir "$data_path"
chown -R $app: "$home_path"
@ -56,9 +56,9 @@ chown -R $app: "$home_path"
ynh_script_progression --message="Installing Octoprint in a virtual environment..."
exec_as $app -H -s /bin/bash -c " \
echo 'create the virtual environment' \
&& virtualenv -p $(which python3) "$final_path" \
&& virtualenv -p $(which python3) "$install_dir" \
&& echo 'install Octoprint' \
&& "$final_path"/bin/pip3 install $app \
&& "$install_dir"/bin/pip3 install $app \
"
# set default configuration files

View file

@ -6,19 +6,19 @@ source _common.sh
source /usr/share/yunohost/helpers
# retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
port=$(ynh_app_setting_get $app port)
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get "$app" domain)
#REMOVEME? port=$(ynh_app_setting_get $app port)
# definie useful vars
final_path="/opt/yunohost/$app"
#REMOVEME? install_dir="/opt/yunohost/$app"
home_path="/home/$app"
# remove metapackage and its dependencies
ynh_remove_app_dependencies
#REMOVEME? ynh_remove_app_dependencies
# remove the app directory securely
ynh_secure_remove "$final_path"
#REMOVEME? ynh_secure_remove "$install_dir"
# remove the dedicated nginx config
ynh_remove_nginx_config
@ -41,7 +41,7 @@ ynh_secure_remove "/etc/systemd/system/$app@$app.service"
ynh_exec_fully_quiet yunohost firewall disallow TCP $port
# delete a system user
ynh_system_user_delete "$app"
#REMOVEME? ynh_system_user_delete "$app"
# remove sudoers file
ynh_secure_remove "/etc/sudoers.d/$app"

View file

@ -8,28 +8,28 @@ source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
# manage script failure
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
# retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
port=$(ynh_app_setting_get "$app" port)
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get "$app" domain)
#REMOVEME? port=$(ynh_app_setting_get "$app" port)
# definie useful vars
final_path="/opt/yunohost/$app"
#REMOVEME? install_dir="/opt/yunohost/$app"
home_path="/home/$app"
data_path="/home/$app/.$app"
# check domain/path availability
path_url=$(ynh_normalize_url_path "/")
ynh_webpath_available $domain $path_url || ynh_die "$domain/$path_url is not available, please use an other domain."
path=$(ynh_normalize_url_path "/")
#REMOVEME? ynh_webpath_available $domain $path || ynh_die "$domain/$path is not available, please use an other domain."
# add required packages
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
#REMOVEME? ynh_install_app_dependencies "$PKG_DEPENDENCIES"
# restore dedicated system user
ynh_system_user_exists "$app" && ynh_die "User $app is not available"
ynh_system_user_create "$app"
#REMOVEME? ynh_system_user_create "$app"
# restore conf files
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
@ -37,10 +37,10 @@ ynh_restore_file "/etc/sudoers.d/$app"
ynh_restore_file "/etc/systemd/system/$app@$app.service"
# restore source
if [ ! -d "$final_path" ]; then
ynh_restore_file "$final_path"
if [ ! -d "$install_dir" ]; then
ynh_restore_file "$install_dir"
else
ynh_die "There is already a directory: $final_path"
ynh_die "There is already a directory: $install_dir"
fi
# restore data
@ -52,7 +52,7 @@ else
fi
# restore port
[ $port -eq $(ynh_find_port $port) ] || ynh_die "$port is not available, please use an other port"
#REMOVEME? [ $port -eq $(ynh_find_port $port) ] || ynh_die "$port is not available, please use an other port"
ynh_exec_fully_quiet yunohost firewall allow TCP $port
# add service in admin panel

View file

@ -4,22 +4,22 @@ source _common.sh
source /usr/share/yunohost/helpers
# manage script failure
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
# retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
port=$(ynh_app_setting_get $app port)
is_public=$(ynh_app_setting_get $app is_public)
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get $app domain)
#REMOVEME? port=$(ynh_app_setting_get $app port)
#REMOVEME? #REMOVEME? is_public=$(ynh_app_setting_get $app is_public)
# definie useful vars
final_path="/opt/yunohost/$app"
#REMOVEME? install_dir="/opt/yunohost/$app"
# use prior backup and restore on error only if backup feature exists on installed instance
if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then
ynh_backup_before_upgrade # Backup the current version of the app
ynh_clean_setup () {
ynh_restore_upgradebackup
#REMOVEME? ynh_backup_before_upgrade # Backup the current version of the app
#REMOVEME? ynh_clean_setup () {
#REMOVEME? ynh_restore_upgradebackup
}
fi
@ -28,7 +28,7 @@ myynh_create_dir "/etc/sudoers.d"
cp "../conf/sudoers" "/etc/sudoers.d/$app"
# add required packages
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
#REMOVEME? ynh_install_app_dependencies "$PKG_DEPENDENCIES"
# stop systemd service
ynh_system_reload --service_name="$app@$app" --action=stop
@ -37,9 +37,9 @@ ynh_system_reload --service_name="$app@$app" --action=disable
# upgrade
exec_as "$app" -H -s /bin/bash -c " \
echo 'create the virtual environment' \
&& python3 -m venv $final_path \
&& python3 -m venv $install_dir \
&& echo 'activate the virtual environment' \
&& source $final_path/bin/activate \
&& source $install_dir/bin/activate \
&& echo 'install a required python package' \
&& pip install --upgrade wheel \
&& echo 'install Octoprint' \