1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/garage_ynh.git synced 2024-09-03 18:36:32 +02:00

change virtualisation helper

This commit is contained in:
oiseauroch 2023-07-30 14:51:43 +02:00
parent 2d606f0a2f
commit f237ed38ac
5 changed files with 18 additions and 69 deletions

View file

@ -48,7 +48,7 @@ ram.runtime = "50M"
[install.weight]
ask.en = "number of G to allow"
ask.fr = "nombre de G à allouer"
type = "string"
type = "number"
[resources]
@ -80,4 +80,6 @@ ram.runtime = "50M"
main.url = "/"
[resources.apt]
packages = "qemu-utils e2fsprogs"
packages_from_raw_bash = """
systemd-detect-virt -q -c && apt install qemu-utils e2fsprogs
"""

View file

@ -26,32 +26,6 @@ fi
GARAGE_VERSION="0.8.2"
# 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 garage 2>&1 >/dev/null
chmod +x garage
}
garage_connect() {
local command="$1"
local peer="$2"

View file

@ -33,25 +33,12 @@ ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret
ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers
ynh_app_setting_set --app=$app --key=weight --value=$weight
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
if [ "$virtualisation" = "true" ]
then
ynh_install_app_dependencies $pkg_dependencies_virtualisation
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_setup_source --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
chmod +x $install_dir/garage
#=================================================

View file

@ -17,8 +17,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
#=================================================
@ -31,8 +29,6 @@ mkdir -p "$data_dir/data"
if [ "$virtualisation" = "true" ]
then
export VIRTUALISATION=true
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies_virtualisation
# to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size.
qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G
$install_dir/mount_disk.sh true

View file

@ -9,13 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
if [ "$virtualisation" = "true" ] ;
then
virt_protection=""
else
virt_protection="#"
fi
#=================================================
# CHECK VERSION
#=================================================
@ -31,16 +24,6 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
if [ "$virtualisation" = "true" ]
then
ynh_install_app_dependencies $pkg_dependencies_virtualisation
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -48,15 +31,10 @@ fi
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
pushd $install_dir
install_garage
popd
ynh_setup_source --dest_dir="$install_dir"
fi
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chmod +x $install_dir/garage
chown -R $app:$app "$install_dir"
#=================================================
@ -85,6 +63,18 @@ ynh_script_progression --message="Upgrading logrotate configuration..." --weigh
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
ynh_script_progression --message="Updating a configuration file..." --weight=1
#=================================================
# UPDATE A CONFIG FILE
#=================================================
### Same as during install
###
### The file will automatically be backed-up if it's found to be manually modified (because
### ynh_add_config keeps track of the file's checksum)
ynh_add_config --template="garage.toml" --destination="$install_dir/garage.toml"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================