1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/beehive_ynh.git synced 2024-09-03 18:06:24 +02:00
This commit is contained in:
ericgaspar 2021-06-13 15:30:36 +02:00
parent 3b78224d22
commit c8c9ae3cfd
No known key found for this signature in database
GPG key ID: 574F281483054D44
2 changed files with 23 additions and 53 deletions

7
conf/app.src Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://github.com/muesli/beehive/releases/download/v0.4.0/beehive_0.4.0_Linux_x86_64.tar.gz
SOURCE_SUM=f1959bc2f7c19d4ec8eaabc7b78492836afcc3bcd75d034854e66607efa9efab
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -33,11 +33,8 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1 ynh_script_progression --message="Validating installation parameters..." --weight=1
### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app"
final_path=/opt/yunohost/$app final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@ -47,7 +44,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
@ -58,82 +55,54 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." --weight=1 ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port # Find an available port
port=$(ynh_find_port --port=8181) port=$(ynh_find_port --port=8181)
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1 ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
# Install Go
tmpdir="$(ynh_smart_mktemp)"
pushd "$tmpdir"
wget https://golang.org/dl/go$GO_VERSION.linux-$architecture.tar.gz
ynh_secure_remove /usr/local/go
tar -C /usr/local -xzf go$GO_VERSION.linux-$architecture.tar.gz
popd
ynh_secure_remove "$tmpdir"
export PATH=$PATH:/usr/local/go/bin
export GOPATH=/usr/local/go/bin
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
git clone --recursive https://github.com/muesli/beehive.git "$final_path" chmod 750 "$final_path"
pushd "$final_path" chmod -R o-rwx "$final_path"
make chown -R $app:www-data "$final_path"
popd
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1 ynh_script_progression --message="Configuring NGINX web server..." --weight=1
### `ynh_add_nginx_config` will use the file conf/nginx.conf
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="port domain" ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
chown -R $app: $final_path
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
@ -147,7 +116,6 @@ ynh_use_logrotate
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app service" --log="/var/log/$app/$app.log" yunohost service add $app --description="$app service" --log="/var/log/$app/$app.log"
#================================================= #=================================================
@ -155,21 +123,16 @@ yunohost service add $app --description="$app service" --log="/var/log/$app/$app
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
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"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1 ynh_script_progression --message="Configuring permissions..." --weight=1
# Only the admin can access the admin panel of the app (if the app has an admin panel) # Only the admin can access the admin panel of the app (if the app has an admin panel)
ynh_permission_update --permission "main" --remove all_users --add $admin ynh_permission_update --permission "main" --remove all_users --add $admin
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================