1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lemmy_ynh.git synced 2024-09-03 19:36:09 +02:00
lemmy_ynh/scripts/_common.sh

52 lines
1.7 KiB
Bash
Raw Normal View History

2021-02-21 06:08:46 +01:00
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
2023-07-12 10:40:28 +02:00
PICTRS_VERSION=0.4.1-rc.0
2021-02-21 06:08:46 +01:00
2023-07-11 08:03:10 +02:00
NODEJS_VERSION=20
2021-02-21 06:08:46 +01:00
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
2023-08-08 20:55:58 +02:00
# Downloads an AppImage from an url, unpacks and extracts it in a destination directory, and creates a symlink to its executable
download_and_install_appimage() {
# Declare an array to define the options of this helper.
local legacy_args=nud
local -A args_array=([n]=name= [u]=url= [d]=directory= [s]=symlink=)
local url
local directory
local name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Cleanup
ynh_secure_remove --file="$install_dir/pict-rs/$name"
ynh_secure_remove --file="$install_dir/pict-rs/$name.appimage"
ynh_secure_remove --file="$install_dir/pict-rs/$name.appimageextract"
# Download and make executable
curl -f "$url" -o "$directory/$name.appimage" -s
[ ! -f "$directory/$name.appimage" ] && ynh_print_err --message="AppImage could not be downloaded"
chmod +x "$directory/$name.appimage"
# Extract and create link
pushd "$directory"
"$directory/$name.appimage" --appimage-extract
mv "$directory/squashfs-root" "$directory/$name.appimageextract"
ln -s "$directory/$name.appimageextract/AppRun" "$directory/$name"
popd
}
2021-02-21 06:08:46 +01:00
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================