diff --git a/README.md b/README.md index f4eaa5a..f9a5a3c 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,16 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Offers a user experience similar to virtual machines but using Linux containers instead. +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. **Shipped version:** 5.3~ynh1 **Demo:** https://linuxcontainers.org/lxd/try-it/ + +## Screenshots + +![Screenshot of LXD](./doc/screenshots/LXD-logo.png) + ## Disclaimers / important information ## Configuration diff --git a/README_fr.md b/README_fr.md index 86042ec..af6326c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -15,16 +15,22 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Offre une expérience utilisateur similaire aux machines virtuelles mais en utilisant des conteneurs Linux à la place. +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. + **Version incluse :** 5.3~ynh1 **Démo :** https://linuxcontainers.org/lxd/try-it/ + +## Captures d'écran + +![Capture d'écran de LXD](./doc/screenshots/LXD-logo.png) + ## Avertissements / informations importantes ## Configuration -How to configure this app: In cli +Comment configurer cette application : en cli ## Documentations et ressources diff --git a/conf/go.x86-64.src b/conf/go.amd64.src similarity index 100% rename from conf/go.x86-64.src rename to conf/go.amd64.src diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..c41d8e6 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -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. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..fe0169b --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -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. diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..d745899 --- /dev/null +++ b/doc/DISCLAIMER_fr.md @@ -0,0 +1,3 @@ +## Configuration + +Comment configurer cette application : en cli diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshots/LXD-logo.png b/doc/screenshots/LXD-logo.png new file mode 100644 index 0000000..e344c1d Binary files /dev/null and b/doc/screenshots/LXD-logo.png differ diff --git a/manifest.json b/manifest.json index 4d0dd1d..8d0e873 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,7 @@ "email": "pierre@kayou.io" }, "requirements": { - "yunohost": ">= 4.2.8" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [], diff --git a/scripts/_common.sh b/scripts/_common.sh index 72aa754..37c653b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -100,22 +100,6 @@ ynh_remove_systemd_socket_config () { # 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 #================================================= diff --git a/scripts/backup b/scripts/backup index 5d5c634..402b1e8 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script diff --git a/scripts/install b/scripts/install index d25d182..0a5e584 100755 --- a/scripts/install +++ b/scripts/install @@ -42,6 +42,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=30 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 #================================================= @@ -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 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 @@ -58,55 +66,38 @@ ynh_setup_source --dest_dir="$lxd_tmp" --source_id="lxd" export GOPATH=${lxd_tmp}/vendor/ +#================================================= +# SPECIFIC SETUP #================================================= # BUILD FROM SOURCES #================================================= ynh_script_progression --message="Building lxd from sources..." --weight=60 pushd ${lxd_tmp} + export HOME=${HOME:-"/root/"} -export HOME=${HOME:-"/root/"} + ynh_exec_warn_less make deps + export CGO_CFLAGS="-I${GOPATH}/raft/include/ -I${GOPATH}/dqlite/include/" + export CGO_LDFLAGS="-L${GOPATH}/raft/.libs -L${GOPATH}/dqlite/.libs/" + export LD_LIBRARY_PATH="${GOPATH}/raft/.libs/:${GOPATH}/dqlite/.libs/" + export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)" -ynh_exec_warn_less make deps -export CGO_CFLAGS="-I${GOPATH}/raft/include/ -I${GOPATH}/dqlite/include/" -export CGO_LDFLAGS="-L${GOPATH}/raft/.libs -L${GOPATH}/dqlite/.libs/" -export LD_LIBRARY_PATH="${GOPATH}/raft/.libs/:${GOPATH}/dqlite/.libs/" -export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)" + ynh_exec_warn_less make -ynh_exec_warn_less make - -mkdir -p /usr/local/lib/$app -mkdir -p /var/log/$app -cp -a ${GOPATH}/{raft,dqlite}/.libs/lib*.so* /usr/local/lib/$app/ -cp ${GOPATH}/bin/{fuidshift,lxc,lxc-to-lxd,lxd,lxd-agent,lxd-benchmark,lxd-migrate,lxd-user} /usr/local/bin -cp ${lxd_tmp}/scripts/bash/lxd-client /etc/bash_completion.d/ + mkdir -p /usr/local/lib/$app + mkdir -p /var/log/$app + cp -a ${GOPATH}/{raft,dqlite}/.libs/lib*.so* /usr/local/lib/$app/ + cp ${GOPATH}/bin/{fuidshift,lxc,lxc-to-lxd,lxd,lxd-agent,lxd-benchmark,lxd-migrate,lxd-user} /usr/local/bin + cp ${lxd_tmp}/scripts/bash/lxd-client /etc/bash_completion.d/ popd ynh_secure_remove --file="$go_tmp" ynh_secure_remove --file="$lxd_tmp" #================================================= -# CREATE DEDICATED USER -#================================================= -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 +# ADD A CONFIGURATION #================================================= +ynh_script_progression --message="Adding a configuration file..." echo "bind-interfaces except-interface=lxdbr0" > /etc/dnsmasq.d/lxd @@ -123,6 +114,15 @@ ldconfig echo "# Added by lxd 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 #================================================= diff --git a/scripts/remove b/scripts/remove index 4bbf943..95203ad 100755 --- a/scripts/remove +++ b/scripts/remove @@ -35,8 +35,19 @@ fi ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config -ynh_remove_systemd_socket_config -ynh_exec_warn_less ynh_remove_systemd_config +ynh_exec_warn_less ynh_remove_systemd_socket_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 @@ -61,6 +72,7 @@ fi #================================================= # REMOVE VARIOUS FILES #================================================= +ynh_script_progression --message="Removing various files..." # Remove a directory securely 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 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 #================================================= diff --git a/scripts/restore b/scripts/restore index b2e217f..635c162 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,8 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -48,25 +47,10 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=30 # Define and install 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 #================================================= +ynh_script_progression --message="Restoring various files..." ynh_restore_file --origin_path="/var/log/$app/" @@ -93,6 +77,22 @@ ldconfig echo "# Added by lxd 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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index de91b2f..0048c21 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,13 +16,6 @@ ynh_script_progression --message="Loading installation settings..." 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 #================================================= @@ -57,56 +50,11 @@ ynh_systemd_action --service_name="$app.socket" --action="stop" 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 - -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Setting up source files..." - -# Download, check integrity, uncompress and patch the source from app.src -go_tmp=$(mktemp -d) -ynh_setup_source --dest_dir="$go_tmp" --source_id="go.$(ynh_detect_arch)" - -export PATH=$go_tmp/bin:$PATH - -lxd_tmp=$(mktemp -d) -ynh_setup_source --dest_dir="$lxd_tmp" --source_id="lxd" - -export GOPATH=${lxd_tmp}/vendor/ - -#================================================= -# BUILD FROM SOURCES -#================================================= -ynh_script_progression --message="Building lxd from sources..." --weight=60 - -pushd ${lxd_tmp} - -export HOME=${HOME:-"/root/"} - -ynh_exec_warn_less make deps -export CGO_CFLAGS="-I${GOPATH}/raft/include/ -I${GOPATH}/dqlite/include/" -export CGO_LDFLAGS="-L${GOPATH}/raft/.libs -L${GOPATH}/dqlite/.libs/" -export LD_LIBRARY_PATH="${GOPATH}/raft/.libs/:${GOPATH}/dqlite/.libs/" -export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)" - -export GOCACHE=$go_tmp - -ynh_exec_warn_less make - -mkdir -p /usr/local/lib/$app -mkdir -p /var/log/$app -cp -a ${GOPATH}/{raft,dqlite}/.libs/lib*.so* /usr/local/lib/$app/ -cp ${GOPATH}/bin/{fuidshift,lxc,lxc-to-lxd,lxd,lxd-agent,lxd-benchmark,lxd-migrate,lxd-user} /usr/local/bin -cp ${lxd_tmp}/scripts/bash/lxd-client /etc/bash_completion.d/ -popd - -ynh_secure_remove --file="$go_tmp" -ynh_secure_remove --file="$lxd_tmp" +sed -i "/root:1000000:65536 # Added by lxd#/d" /etc/sub{u,g}id #================================================= # CREATE DEDICATED USER @@ -116,20 +64,63 @@ 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 +#================================================= +ynh_script_progression --message="Setting up source files..." + +# Download, check integrity, uncompress and patch the source from app.src +go_tmp=$(mktemp -d) +ynh_setup_source --dest_dir="$go_tmp" --source_id="go.$YNH_ARCH" + +export PATH=$go_tmp/bin:$PATH + +lxd_tmp=$(mktemp -d) +ynh_setup_source --dest_dir="$lxd_tmp" --source_id="lxd" + +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 #================================================= -# SETUP SYSTEMD +# BUILD FROM SOURCES #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression --message="Building lxd from sources..." --weight=60 -# Create a dedicated systemd config -ynh_add_systemd_socket_config -ynh_add_systemd_config +pushd ${lxd_tmp} + export HOME=${HOME:-"/root/"} + + ynh_exec_warn_less make deps + export CGO_CFLAGS="-I${GOPATH}/raft/include/ -I${GOPATH}/dqlite/include/" + export CGO_LDFLAGS="-L${GOPATH}/raft/.libs -L${GOPATH}/dqlite/.libs/" + export LD_LIBRARY_PATH="${GOPATH}/raft/.libs/:${GOPATH}/dqlite/.libs/" + export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)" + + export GOCACHE=$go_tmp + + ynh_exec_warn_less make + + mkdir -p /usr/local/lib/$app + mkdir -p /var/log/$app + cp -a ${GOPATH}/{raft,dqlite}/.libs/lib*.so* /usr/local/lib/$app/ + cp ${GOPATH}/bin/{fuidshift,lxc,lxc-to-lxd,lxd,lxd-agent,lxd-benchmark,lxd-migrate,lxd-user} /usr/local/bin + cp ${lxd_tmp}/scripts/bash/lxd-client /etc/bash_completion.d/ +popd + +ynh_secure_remove --file="$go_tmp" +ynh_secure_remove --file="$lxd_tmp" #================================================= -# MODIFY A CONFIG FILE +# UPDATE A CONFIG FILE #================================================= +ynh_script_progression --message="Updating a configuration file..." ynh_backup_if_checksum_is_different --file="/etc/dnsmasq.d/lxd" @@ -150,6 +141,15 @@ ldconfig echo "# Added by lxd 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 #================================================= @@ -164,7 +164,6 @@ yunohost service add $app --log="/var/log/$app/$app.log" #================================================= 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" #=================================================