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

Merge pull request #87 from YunoHost-Apps/manifestv2

Manifestv2
This commit is contained in:
Salamandar 2024-02-02 15:04:27 +01:00 committed by GitHub
commit de909638b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 240 additions and 621 deletions

View file

@ -1,162 +0,0 @@
#!/bin/bash
#=================================================
# PACKAGE UPDATING HELPER
#=================================================
# This script is meant to be run by GitHub Actions
# The YunoHost-Apps organisation offers a template Action to run this script periodically
# Since each app is different, maintainers can adapt its contents so as to perform
# automatic actions when a new upstream release is detected.
#=================================================
# FETCHING LATEST RELEASE AND ITS ASSETS
#=================================================
# Fetching information
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
# Later down the script, we assume the version has only digits and dots
# Sometimes the release name starts with a "v", so let's filter it out.
# You may need more tweaks here if the upstream repository has different naming conventions.
if [[ ${version:0:3} == "lxd" ]]; then
version=${version:4}
fi
# Setting up the environment variables
echo "Current version: $current_version"
echo "Latest release from upstream: $version"
echo "VERSION=$version" >> $GITHUB_ENV
# For the time being, let's assume the script will fail
echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
echo "::warning ::No new version available"
exit 0
# Proceed only if a PR for this new version does not already exist
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
echo "::warning ::A branch already exists for this update"
exit 0
fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)"
#=================================================
# UPDATE SOURCE FILES
#=================================================
# Here we use the $assets variable to get the resources published in the upstream release.
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like.
# Let's loop over the array of assets URLs
for asset_url in "${assets[@]}"; do
echo "Handling asset at $asset_url"
src="lxd"
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download sources and calculate checksum
filename=${asset_url##*/}
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory
rm -rf $tempdir
# Get extension
if [[ $filename == *.tar.gz ]]; then
extension=tar.gz
else
echo "... asset ignored"
continue
fi
# Rewrite source file
cat <<EOT > conf/$src.src
SOURCE_URL=$asset_url
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true
EOT
echo "... conf/$src.src updated"
done
#=================================================
# Update Go
#=================================================
go_url="https://go.dev/dl/?mode=json"
go_version=$(curl --silent "$go_url" | jq -r '.[] | .version' | sort -V | tail -1)
go_arch=($(curl --silent "$go_url" | jq -r '.[] | select(.version=="'$go_version'") | .files[] | select(.os == "linux") | .arch'))
for arch in "${go_arch[@]}"
do
filename=$(curl --silent "$go_url" | jq -r '.[] | select(.version=="'$go_version'") | .files[] | select(.os == "linux") | select(.arch == "'$arch'") | .filename')
checksum=$(curl --silent "$go_url" | jq -r '.[] | select(.version=="'$go_version'") | .files[] | select(.os == "linux") | select(.arch == "'$arch'") | .sha256')
case $arch in
*"amd64"*)
src="amd64"
;;
*"386"*)
src="i386"
;;
*"arm64"*)
src="arm64"
;;
*"armv6l"*)
src="arm"
;;
*)
src=""
;;
esac
if [ -z "$src" ]; then
continue
fi
# Rewrite source file
cat <<EOT > conf/go.$src.src
SOURCE_URL=https://go.dev/dl/$filename
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true
EOT
echo "... conf/go.$src.src updated"
done
#=================================================
# SPECIFIC UPDATE STEPS
#=================================================
# Any action on the app's source code can be done.
# The GitHub Action workflow takes care of committing all changes after this script ends.
#=================================================
# GENERIC FINALIZATION
#=================================================
# Replace new version in manifest
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
# No need to update the README, yunohost-bot takes care of it
# The Action will proceed only if the PROCEED environment variable is set to true
echo "PROCEED=true" >> $GITHUB_ENV
exit 0

View file

@ -1,49 +0,0 @@
# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected.
# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization.
# This file should be enough by itself, but feel free to tune it to your needs.
# It calls updater.sh, which is where you should put the app-specific update steps.
name: Check for new upstream releases
on:
# Allow to manually trigger the workflow
workflow_dispatch:
# Run it every day at 6:00 UTC
schedule:
- cron: '0 6 * * *'
jobs:
updater:
runs-on: ubuntu-latest
steps:
- name: Fetch the source code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run the updater script
id: run_updater
run: |
# Setting up Git user
git config --global user.name 'yunohost-bot'
git config --global user.email 'yunohost-bot@users.noreply.github.com'
# Run the updater script
/bin/bash .github/workflows/updater.sh
- name: Commit changes
id: commit
if: ${{ env.PROCEED == 'true' }}
run: |
git commit -am "Upgrade to v$VERSION"
- name: Create Pull Request
id: cpr
if: ${{ env.PROCEED == 'true' }}
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update to version ${{ env.VERSION }}
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
signoff: false
base: testing
branch: ci-auto-update-v${{ env.VERSION }}
delete-branch: true
title: 'Upgrade to version ${{ env.VERSION }}'
body: |
Upgrade to v${{ env.VERSION }}
draft: false

View file

@ -26,12 +26,6 @@ LXD is a next generation system container and virtual machine manager. It offers
![Screenshot of LXD](./doc/screenshots/LXD-logo.png) ![Screenshot of LXD](./doc/screenshots/LXD-logo.png)
## Disclaimers / important information
## Configuration
How to configure this app: In cli
## Documentation and resources ## Documentation and resources
* Official app website: <https://linuxcontainers.org/lxd/> * Official app website: <https://linuxcontainers.org/lxd/>

View file

@ -27,12 +27,6 @@ LXD est un gestionnaire de conteneurs système et de machines virtuelles de nouv
![Capture décran de LXD](./doc/screenshots/LXD-logo.png) ![Capture décran de LXD](./doc/screenshots/LXD-logo.png)
## Avertissements / informations importantes
## Configuration
Comment configurer cette application : en cli
## Documentations et ressources ## Documentations et ressources
* Site officiel de lapp : <https://linuxcontainers.org/lxd/> * Site officiel de lapp : <https://linuxcontainers.org/lxd/>

View file

@ -1,12 +0,0 @@
;; Test complet
; Manifest
; Checks
pkg_linter=1
setup_nourl=1
upgrade=1
upgrade=1 from_commit=b66ae64c2dae8595c817f058c4e45cd7cc40ac64
backup_restore=1
;;; Options
Email=
Notification=none

2
conf/dnsmasq.conf Normal file
View file

@ -0,0 +1,2 @@
bind-interfaces
except-interface=lxdbr0

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://go.dev/dl/go1.21.5.linux-amd64.tar.gz
SOURCE_SUM=e2bc0b3e4b64111ec117295c088bde5f00eeed1567999ff77bc859d7df70078e
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://go.dev/dl/go1.21.5.linux-armv6l.tar.gz
SOURCE_SUM=837f4bf4e22fcdf920ffeaa4abf3d02d1314e03725431065f4d44c46a01b42fe
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://go.dev/dl/go1.21.5.linux-arm64.tar.gz
SOURCE_SUM=841cced7ecda9b2014f139f5bab5ae31785f35399f236b8b3e75dff2a2978d96
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://go.dev/dl/go1.21.5.linux-386.tar.gz
SOURCE_SUM=8f4dba9cf5c61757bbd7e9ebdb93b6a30a1b03f4a636a1ba0cc2f27b907ab8e1
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

1
conf/ld.so.conf Normal file
View file

@ -0,0 +1 @@
/usr/local/lib/__APP__/

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/canonical/lxd/releases/download/lxd-5.20/lxd-5.20.tar.gz
SOURCE_SUM=2f958b757f4cde64d0f3578da0bda9ee5965a3a70ec0956eddf8287d1290167f
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,31 +0,0 @@
{
"name": "LXD",
"id": "lxd",
"packaging_format": 1,
"description": {
"en": "Offers a user experience similar to virtual machines but using Linux containers instead.",
"fr": "Offre une expérience utilisateur similaire aux machines virtuelles mais en utilisant des conteneurs Linux à la place."
},
"version": "5.20~ynh1",
"url": "https://example.com",
"upstream": {
"license": "Apache-2.0",
"website": "https://linuxcontainers.org/lxd/",
"demo": "https://linuxcontainers.org/lxd/try-it/",
"admindoc": "https://linuxcontainers.org/lxd/docs/master/index.html",
"code": "https://github.com/canonical/lxd"
},
"license": "Apache-2.0",
"maintainer": {
"name": "kay0u",
"email": "pierre@kayou.io"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [],
"arguments": {
"install": []
}
}

97
manifest.toml Normal file
View file

@ -0,0 +1,97 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "lxd"
name = "LXD"
description.en = "Offers a user experience similar to virtual machines but using Linux containers instead."
description.fr = "Offre une expérience utilisateur similaire aux machines virtuelles mais en utilisant des conteneurs Linux à la place."
version = "5.20~ynh1"
maintainers = ["kay0u"]
[upstream]
license = "Apache-2.0"
website = "https://linuxcontainers.org/lxd/"
demo = "https://linuxcontainers.org/lxd/try-it/"
admindoc = "https://linuxcontainers.org/lxd/docs/master/index.html"
code = "https://github.com/canonical/lxd"
cpe = "cpe:2.3:a:canonical:lxd"
[integration]
yunohost = ">= 4.3.0"
architectures = "all"
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"
disk = "500M"
ram.build = "600M"
ram.runtime = "500M"
[install]
[resources]
[resources.sources]
[resources.sources.go]
amd64.url = "https://go.dev/dl/go1.21.5.linux-amd64.tar.gz"
amd64.sha256 = "e2bc0b3e4b64111ec117295c088bde5f00eeed1567999ff77bc859d7df70078e"
i386.url = "https://go.dev/dl/go1.21.5.linux-386.tar.gz"
i386.sha256 = "8f4dba9cf5c61757bbd7e9ebdb93b6a30a1b03f4a636a1ba0cc2f27b907ab8e1"
arm64.url = "https://go.dev/dl/go1.21.5.linux-arm64.tar.gz"
arm64.sha256 = "841cced7ecda9b2014f139f5bab5ae31785f35399f236b8b3e75dff2a2978d96"
armhf.url = "https://go.dev/dl/go1.21.5.linux-armv6l.tar.gz"
armhf.sha256 = "837f4bf4e22fcdf920ffeaa4abf3d02d1314e03725431065f4d44c46a01b42fe"
[resources.sources.lxd]
url = "https://github.com/canonical/lxd/releases/download/lxd-5.20/lxd-5.20.tar.gz"
sha256 = "2f958b757f4cde64d0f3578da0bda9ee5965a3a70ec0956eddf8287d1290167f"
autoupdate.strategy = "latest_github_release"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
[resources.apt]
packages = [
"acl",
"attr",
"autoconf",
"dnsmasq-base",
"git",
"libacl1-dev",
"libcap-dev",
"liblxc1",
"lxc-dev",
"libsqlite3-dev",
"libtool",
"libudev-dev",
"liblz4-dev",
"libuv1-dev",
"make",
"pkg-config",
"rsync",
"squashfs-tools",
"tar",
"tcl",
"xz-utils",
"ebtables",
"libapparmor-dev",
"libseccomp-dev",
"libcap-dev",
"lvm2",
"thin-provisioning-tools",
"btrfs-progs",
"busybox",
"libattr1-dev",
"libuv1",
"libdevmapper-event1.02.1",
"dmeventd",
"lxc",
"tcl8.6",
# For debuging
"iproute2",
]

View file

@ -4,9 +4,6 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app
pkg_dependencies="acl attr autoconf dnsmasq-base git libacl1-dev libcap-dev liblxc1 lxc-dev libsqlite3-dev libtool libudev-dev liblz4-dev libuv1-dev make pkg-config rsync squashfs-tools tar tcl xz-utils ebtables libapparmor-dev libseccomp-dev libcap-dev lvm2 thin-provisioning-tools btrfs-progs busybox|busybox-static libattr1-dev libuv1 libdevmapper-event1.02.1 dmeventd lxc tcl8.6"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
@ -96,6 +93,52 @@ ynh_remove_systemd_socket_config () {
fi fi
} }
_ynh_add_dnsmasq() {
# Declare an array to define the options of this helper.
local legacy_args=t
local -A args_array=( [t]=template= )
local template
ynh_handle_getopts_args "$@"
local template="${template:-dnsmasq.conf}"
ynh_add_config --template="$template" --destination="/etc/dnsmasq.d/$app"
ynh_systemd_action --service_name=dnsmasq --action=restart
}
_ynh_remove_dnsmasq() {
ynh_secure_remove --file="/etc/dnsmasq.d/$app"
ynh_systemd_action --service_name=dnsmasq --action=restart
}
_ynh_add_ld_so() {
# Declare an array to define the options of this helper.
local legacy_args=t
local -A args_array=( [t]=template= )
local template
ynh_handle_getopts_args "$@"
local template="${template:-ld.so.conf}"
ynh_add_config --template="$template" --destination="/etc/ld.so.conf.d/$app.conf"
ldconfig
}
_ynh_remove_ld_so() {
ynh_secure_remove --file="/etc/ld.so.conf.d/$app.conf"
ldconfig
}
_ynh_set_subuid_subgid() {
echo -e "# Added by lxd\nroot:100000:65536" | tee -a /etc/subuid /etc/subgid
}
_ynh_unset_subuid_subgid() {
sed -i "/# Added by lxd$/{N;/root:100000:65536/d}" /etc/sub{u,g}id
}
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -10,23 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================

View file

@ -9,62 +9,14 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_exec_warn_less popd
ynh_secure_remove --file="$go_tmp"
ynh_secure_remove --file="$lxd_tmp"
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
app=$YNH_APP_INSTANCE_NAME
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..."
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
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 # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=5 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) ynh_setup_source --source_id="go" --dest_dir="$install_dir/go"
ynh_setup_source --dest_dir="$go_tmp" --source_id="go.$YNH_ARCH" ynh_setup_source --source_id="lxd" --dest_dir="$install_dir/lxd"
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/
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -73,64 +25,51 @@ export GOPATH=${lxd_tmp}/vendor/
#================================================= #=================================================
ynh_script_progression --message="Building lxd from sources..." --weight=60 ynh_script_progression --message="Building lxd from sources..." --weight=60
pushd ${lxd_tmp} pushd "$install_dir/lxd"
export HOME=${HOME:-"/root/"} (
export PATH="$install_dir/go/bin:$PATH"
export GOPATH="$install_dir/lxd/vendor/"
export HOME=${HOME:-"/root/"}
ynh_exec_warn_less make deps ynh_exec_warn_less make deps
export CGO_CFLAGS="-I${GOPATH}/raft/include/ -I${GOPATH}/dqlite/include/" export CGO_CFLAGS="-I${GOPATH}/raft/include/ -I${GOPATH}/dqlite/include/"
export CGO_LDFLAGS="-L${GOPATH}/raft/.libs -L${GOPATH}/dqlite/.libs/" export CGO_LDFLAGS="-L${GOPATH}/raft/.libs -L${GOPATH}/dqlite/.libs/"
export LD_LIBRARY_PATH="${GOPATH}/raft/.libs/:${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 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 /usr/local/lib/$app
mkdir -p /var/log/$app mkdir -p /var/log/$app
cp -a ${GOPATH}/{raft,dqlite}/.libs/lib*.so* /usr/local/lib/$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 ${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/ cp $install_dir/lxd/scripts/bash/lxd-client /etc/bash_completion.d/
)
popd popd
ynh_secure_remove --file="$go_tmp" ynh_secure_remove --file="$install_dir/go"
ynh_secure_remove --file="$lxd_tmp" ynh_secure_remove --file="$install_dir/lxd"
#================================================= #=================================================
# ADD A CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
echo "bind-interfaces
except-interface=lxdbr0" > /etc/dnsmasq.d/lxd
systemctl restart dnsmasq
ynh_store_file_checksum --file="/etc/dnsmasq.d/lxd"
echo "/usr/local/lib/$app/" > /etc/ld.so.conf.d/$app.conf
ynh_store_file_checksum --file="/etc/ld.so.conf.d/$app.conf"
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 # Create a dedicated systemd config
ynh_add_systemd_socket_config ynh_add_systemd_socket_config
ynh_add_systemd_config ynh_add_systemd_config
yunohost service add "$app" --log="/var/log/$app/$app.log"
#================================================= ynh_exec_warn ss -lp "sport = :domain"
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log" _ynh_add_dnsmasq
ynh_exec_warn ss -lp "sport = :domain"
_ynh_add_ld_so
_ynh_set_subuid_subgid
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -138,7 +77,7 @@ 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 # 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"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -10,59 +10,42 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
then yunohost service remove "$app"
ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app
fi fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_exec_warn_less 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
# Stop LXC systemd services for dnsmasq.
ynh_systemd_action --service_name="lxc-net" --action="stop"
ynh_systemd_action --service_name="lxc" --action="stop"
_ynh_remove_ld_so
_ynh_unset_subuid_subgid
_ynh_remove_dnsmasq
#================================================= #=================================================
# REMOVE CONTAINERS # REMOVE CONTAINERS
#================================================= #=================================================
# Remove the data directory if --purge option is used # Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ] if [ "${YNH_APP_PURGE:-0}" -eq 1 ]; then
then
ynh_script_progression --message="Removing containers..." ynh_script_progression --message="Removing containers..."
ynh_secure_remove --file="/var/lib/lxd" ynh_secure_remove --file="/var/lib/lxd"
fi fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=20
# Remove metapackage and its dependencies
ynh_exec_warn_less ynh_remove_app_dependencies
#================================================= #=================================================
# CLOSE A PORT # CLOSE A PORT
#================================================= #=================================================
if yunohost firewall list | grep -q "\- 67$"; then
if yunohost firewall list | grep -q "\- 67$"
then
ynh_script_progression --message="Closing port 67..." ynh_script_progression --message="Closing port 67..."
ynh_exec_warn_less yunohost firewall disallow Both 67 ynh_exec_warn_less yunohost firewall disallow Both 67
fi fi
@ -74,11 +57,6 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Removing various files..." ynh_script_progression --message="Removing various files..."
# Remove a directory securely
ynh_secure_remove --file="/etc/ld.so.conf.d/$app.conf"
ldconfig
ynh_secure_remove --file="/usr/local/lib/$app" ynh_secure_remove --file="/usr/local/lib/$app"
# Remove the log files # Remove the log files
@ -94,22 +72,6 @@ ynh_secure_remove --file="/usr/local/bin/lxd-migrate"
ynh_secure_remove --file="/usr/local/bin/lxd-user" ynh_secure_remove --file="/usr/local/bin/lxd-user"
ynh_secure_remove --file="/etc/bash_completion.d/lxd-client" ynh_secure_remove --file="/etc/bash_completion.d/lxd-client"
sed -i "/# Added by lxd$/{N;/root:100000:65536/d}" /etc/sub{u,g}id
ynh_secure_remove --file="/etc/dnsmasq.d/lxd"
systemctl restart dnsmasq
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,43 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=30
# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
@ -66,39 +29,31 @@ ynh_restore_file --origin_path="/usr/local/bin/lxd-migrate"
ynh_restore_file --origin_path="/usr/local/bin/lxd-user" ynh_restore_file --origin_path="/usr/local/bin/lxd-user"
ynh_restore_file --origin_path="/etc/bash_completion.d/lxd-client" ynh_restore_file --origin_path="/etc/bash_completion.d/lxd-client"
ynh_restore_file --origin_path="/etc/dnsmasq.d/lxd"
systemctl restart dnsmasq
ynh_restore_file --origin_path="/etc/ld.so.conf.d/$app.conf"
ldconfig
echo "# Added by lxd
root:100000:65536" | tee -a /etc/subuid /etc/subgid
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app.socket" ynh_restore_file --origin_path="/etc/systemd/system/$app.socket"
systemctl enable $app.service --quiet systemctl enable "$app.service" --quiet
#================================================= yunohost service add "$app" --log="/var/log/$app/$app.log"
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log" ynh_restore_file --origin_path="/etc/dnsmasq.d/lxd"
systemctl restart dnsmasq
ynh_restore_file --origin_path="/etc/ld.so.conf.d/$app.conf"
ldconfig
_ynh_set_subuid_subgid
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting 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"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -9,36 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_exec_warn_less popd
ynh_secure_remove --file="$go_tmp"
ynh_secure_remove --file="$lxd_tmp"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Remove old file
if [ -f "/usr/local/bin/lxd-p2c" ]; then
ynh_secure_remove --file="/usr/local/bin/lxd-p2c"
fi
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -47,45 +17,33 @@ fi
ynh_script_progression --message="Stopping a systemd service..." ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name="$app.socket" --action="stop" 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"
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Remove old file
if [ -f "/usr/local/bin/lxd-p2c" ]; then
ynh_secure_remove --file="/usr/local/bin/lxd-p2c"
fi
sed -i "/root:1000000:65536 # Added by lxd#/d" /etc/sub{u,g}id 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
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." 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) ynh_setup_source --source_id="go" --dest_dir="$install_dir/go" --full_replace=1
ynh_setup_source --dest_dir="$go_tmp" --source_id="go.$YNH_ARCH"
export PATH=$go_tmp/bin:$PATH export PATH="$install_dir/go/bin:$PATH"
lxd_tmp=$(mktemp -d) ynh_setup_source --source_id="lxd" --dest_dir="$install_dir/lxd" --full_replace=1
ynh_setup_source --dest_dir="$lxd_tmp" --source_id="lxd"
export GOPATH=${lxd_tmp}/vendor/ export GOPATH="$install_dir/lxd/vendor/"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -94,7 +52,7 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
ynh_script_progression --message="Building lxd from sources..." --weight=60 ynh_script_progression --message="Building lxd from sources..." --weight=60
pushd ${lxd_tmp} pushd "$install_dir/lxd"
export HOME=${HOME:-"/root/"} export HOME=${HOME:-"/root/"}
ynh_exec_warn_less make deps ynh_exec_warn_less make deps
@ -103,68 +61,41 @@ pushd ${lxd_tmp}
export LD_LIBRARY_PATH="${GOPATH}/raft/.libs/:${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 CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
export GOCACHE=$go_tmp
ynh_exec_warn_less make ynh_exec_warn_less make
mkdir -p /usr/local/lib/$app mkdir -p /usr/local/lib/$app
mkdir -p /var/log/$app mkdir -p /var/log/$app
cp -a ${GOPATH}/{raft,dqlite}/.libs/lib*.so* /usr/local/lib/$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 ${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/ cp $install_dir/lxd/scripts/bash/lxd-client /etc/bash_completion.d/
popd popd
ynh_secure_remove --file="$go_tmp" ynh_secure_remove --file="$install_dir/go"
ynh_secure_remove --file="$lxd_tmp" ynh_secure_remove --file="$install_dir/lxd"
#================================================= #=================================================
# UPDATE A CONFIG FILE # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_backup_if_checksum_is_different --file="/etc/dnsmasq.d/lxd"
echo "bind-interfaces
except-interface=lxdbr0" > /etc/dnsmasq.d/lxd
systemctl restart dnsmasq
ynh_store_file_checksum --file="/etc/dnsmasq.d/lxd"
ynh_backup_if_checksum_is_different --file="/etc/ld.so.conf.d/$app.conf"
echo "/usr/local/lib/$app/" > /etc/ld.so.conf.d/$app.conf
ynh_store_file_checksum --file="/etc/ld.so.conf.d/$app.conf"
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 # Create a dedicated systemd config
ynh_add_systemd_socket_config ynh_add_systemd_socket_config
ynh_add_systemd_config ynh_add_systemd_config
yunohost service add "$app" --log="/var/log/$app/$app.log"
#================================================= _ynh_add_dnsmasq
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log" _ynh_add_ld_so
_ynh_set_subuid_subgid
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting 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"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

7
tests.toml Normal file
View file

@ -0,0 +1,7 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
test_upgrade_from.b66ae64c2dae8595c817f058c4e45cd7cc40ac64.name = "5.16~ynh1"