1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lxd_ynh.git synced 2024-09-03 19:45:53 +02:00

Apply last example_ynh

This commit is contained in:
yalh76 2022-07-27 20:53:30 +02:00
parent 07ad3599e2
commit 189d7138f9
12 changed files with 133 additions and 145 deletions

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
LXD is a next generation system container and virtual machine manager. It offers a unified user experience around full Linux systems running inside containers or virtual machines.

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
LXD est un gestionnaire de conteneurs système et de machines virtuelles de nouvelle génération. Il offre une expérience utilisateur unifiée autour de systèmes Linux complets fonctionnant dans des conteneurs ou des machines virtuelles.

3
doc/DISCLAIMER_fr.md Normal file
View file

@ -0,0 +1,3 @@
## Configuration
Comment configurer cette application : en cli

0
doc/screenshots/.gitkeep Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

View file

@ -21,7 +21,7 @@
"email": "pierre@kayou.io" "email": "pierre@kayou.io"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.2.8" "yunohost": ">= 4.3.0"
}, },
"multi_instance": false, "multi_instance": false,
"services": [], "services": [],

View file

@ -100,22 +100,6 @@ ynh_remove_systemd_socket_config () {
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
ynh_detect_arch(){
local architecture
if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then
architecture="arm64"
elif [ -n "$(uname -m | grep 64)" ]; then
architecture="x86-64"
elif [ -n "$(uname -m | grep 86)" ]; then
architecture="i386"
elif [ -n "$(uname -m | grep arm)" ]; then
architecture="arm"
else
architecture="unknown"
fi
echo $architecture
}
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # FUTURE OFFICIAL HELPERS
#================================================= #=================================================

View file

@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script

View file

@ -42,6 +42,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=30
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -49,7 +57,7 @@ ynh_script_progression --message="Setting up source files..." --weight=5
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
go_tmp=$(mktemp -d) go_tmp=$(mktemp -d)
ynh_setup_source --dest_dir="$go_tmp" --source_id="go.$(ynh_detect_arch)" ynh_setup_source --dest_dir="$go_tmp" --source_id="go.$YNH_ARCH"
export PATH=$go_tmp/bin:$PATH export PATH=$go_tmp/bin:$PATH
@ -58,13 +66,14 @@ ynh_setup_source --dest_dir="$lxd_tmp" --source_id="lxd"
export GOPATH=${lxd_tmp}/vendor/ export GOPATH=${lxd_tmp}/vendor/
#=================================================
# SPECIFIC SETUP
#================================================= #=================================================
# BUILD FROM SOURCES # BUILD FROM SOURCES
#================================================= #=================================================
ynh_script_progression --message="Building lxd from sources..." --weight=60 ynh_script_progression --message="Building lxd from sources..." --weight=60
pushd ${lxd_tmp} pushd ${lxd_tmp}
export HOME=${HOME:-"/root/"} export HOME=${HOME:-"/root/"}
ynh_exec_warn_less make deps ynh_exec_warn_less make deps
@ -86,27 +95,9 @@ ynh_secure_remove --file="$go_tmp"
ynh_secure_remove --file="$lxd_tmp" ynh_secure_remove --file="$lxd_tmp"
#================================================= #=================================================
# CREATE DEDICATED USER # ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app
#=================================================
# SPECIFIC SETUP
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_socket_config
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..."
echo "bind-interfaces echo "bind-interfaces
except-interface=lxdbr0" > /etc/dnsmasq.d/lxd except-interface=lxdbr0" > /etc/dnsmasq.d/lxd
@ -123,6 +114,15 @@ ldconfig
echo "# Added by lxd echo "# Added by lxd
root:100000:65536" | tee -a /etc/subuid /etc/subgid root:100000:65536" | tee -a /etc/subuid /etc/subgid
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_socket_config
ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -35,9 +35,20 @@ fi
ynh_script_progression --message="Stopping and removing the systemd service..." ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_socket_config ynh_exec_warn_less ynh_remove_systemd_socket_config
ynh_exec_warn_less ynh_remove_systemd_config ynh_exec_warn_less ynh_remove_systemd_config
#=================================================
# REMOVE CONTAINERS
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing containers..."
ynh_secure_remove --file="/var/lib/lxd"
fi
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
@ -61,6 +72,7 @@ fi
#================================================= #=================================================
# REMOVE VARIOUS FILES # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing various files..."
# Remove a directory securely # Remove a directory securely
ynh_secure_remove --file="/etc/ld.so.conf.d/$app.conf" ynh_secure_remove --file="/etc/ld.so.conf.d/$app.conf"
@ -98,17 +110,6 @@ ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app
#=================================================
# REMOVE CONTAINERS
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing containers..."
ynh_secure_remove --file="/var/lib/lxd"
fi
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -15,8 +15,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script. ynh_clean_check_starting
true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -48,25 +47,10 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=30
# Define and install dependencies # Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app.socket"
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log"
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/var/log/$app/" ynh_restore_file --origin_path="/var/log/$app/"
@ -93,6 +77,22 @@ ldconfig
echo "# Added by lxd echo "# Added by lxd
root:100000:65536" | tee -a /etc/subuid /etc/subgid root:100000:65536" | tee -a /etc/subuid /etc/subgid
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app.socket"
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================

View file

@ -16,13 +16,6 @@ ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
sed -i "/root:1000000:65536 # Added by lxd#/d" /etc/sub{u,g}id
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
@ -57,11 +50,19 @@ ynh_systemd_action --service_name="$app.socket" --action="stop"
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# UPGRADE DEPENDENCIES # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." ynh_script_progression --message="Ensuring downward compatibility..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies sed -i "/root:1000000:65536 # Added by lxd#/d" /etc/sub{u,g}id
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -70,7 +71,7 @@ ynh_script_progression --message="Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
go_tmp=$(mktemp -d) go_tmp=$(mktemp -d)
ynh_setup_source --dest_dir="$go_tmp" --source_id="go.$(ynh_detect_arch)" ynh_setup_source --dest_dir="$go_tmp" --source_id="go.$YNH_ARCH"
export PATH=$go_tmp/bin:$PATH export PATH=$go_tmp/bin:$PATH
@ -79,13 +80,21 @@ ynh_setup_source --dest_dir="$lxd_tmp" --source_id="lxd"
export GOPATH=${lxd_tmp}/vendor/ export GOPATH=${lxd_tmp}/vendor/
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC UPGRADE
#================================================= #=================================================
# BUILD FROM SOURCES # BUILD FROM SOURCES
#================================================= #=================================================
ynh_script_progression --message="Building lxd from sources..." --weight=60 ynh_script_progression --message="Building lxd from sources..." --weight=60
pushd ${lxd_tmp} pushd ${lxd_tmp}
export HOME=${HOME:-"/root/"} export HOME=${HOME:-"/root/"}
ynh_exec_warn_less make deps ynh_exec_warn_less make deps
@ -109,27 +118,9 @@ ynh_secure_remove --file="$go_tmp"
ynh_secure_remove --file="$lxd_tmp" ynh_secure_remove --file="$lxd_tmp"
#================================================= #=================================================
# CREATE DEDICATED USER # UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# SPECIFIC UPGRADE
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_socket_config
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_backup_if_checksum_is_different --file="/etc/dnsmasq.d/lxd" ynh_backup_if_checksum_is_different --file="/etc/dnsmasq.d/lxd"
@ -150,6 +141,15 @@ ldconfig
echo "# Added by lxd echo "# Added by lxd
root:100000:65536" | tee -a /etc/subuid /etc/subgid root:100000:65536" | tee -a /etc/subuid /etc/subgid
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_add_systemd_socket_config
ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -164,7 +164,6 @@ yunohost service add $app --log="/var/log/$app/$app.log"
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================