1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/galene_ynh.git synced 2024-09-03 18:36:31 +02:00
galene_ynh/scripts/install
Éric Gaspar 208b5947ce
Testing (#107)
* Stop auto updating for now

* Update manifest.json

* Update ynh_install_go

* Update ynh_install_go

* Update ldap.src

* Add feature to readme

* Auto-update README

* 0.6.2

* Auto-update README

* cleaning

* Auto-update README

* Auto-update README

* Update systemd.service

* Upgrade auto-updater (#106)

* [autopatch] Upgrade auto-updater

* Auto-update README

---------

Co-authored-by: tituspijean <titus@pijean.ovh>

* Galene v2 (#104)

* v2

* Fix

* Auto-update README

* Fix

* fix

* Fix

* Fix

* Auto-update README

* Fix

* Auto-update README

* Fix

* Auto-update README

* Update tests.toml

* Fix

* Update manifest.toml

* Update manifest.toml

* Update tests.toml

* Update tests.toml

* Update tests.toml

* Update tests.toml

* Update tests.toml

* Update restore

* Update install

* Update upgrade

* Update manifest.toml

* Update ynh_install_go

* Update change_url

* Auto-update README

* Update change_url

* fix

* Update change_url

* Update change_url

* Update manifest.toml

* fix

* Update systemd.service

* Update systemd.service

* Update systemd.service

* Update systemd.service

* Update systemd.service

* Update upgrade

* Update upgrade

* Update install

* Update upgrade

* Update manifest.toml

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>

* Update manifest.toml

* Auto-update README

* Update manifest.toml

* Fix

* Update DESCRIPTION.md

* Auto-update README

* Create POST_INSTALL.md

* Auto-update README

* fix

* Auto-update README

* Create POST_INSTALL_fr.md

* Fix

* Fix

* Update change_url

* Update manifest.toml

* Delete app.src

* fix

* Update manifest.toml

* cleaning

* Update manifest.toml

* Update manifest.toml

* Update manifest.toml

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: YunoHost Bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: tituspijean <titus@pijean.ovh>
2023-03-10 07:59:41 +01:00

159 lines
6.2 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source ynh_install_go
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
group_name=$YNH_APP_ARG_GROUP_NAME
group_description=$YNH_APP_ARG_GROUP_DESCRIPTION
password=$YNH_APP_ARG_PASSWORD
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=4
ynh_app_setting_set --app=$app --key=group_name --value="$group_name"
ynh_app_setting_set --app=$app --key=group_description --value="$group_description"
ynh_app_setting_set --app=$app --key=password --value="$password"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Configuring firewall..." --weight=1
# Reserve UDP Port range 49152:65535
ynh_exec_warn_less yunohost firewall allow UDP -4 49152:65535
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir/build"
ynh_setup_source --dest_dir="$install_dir/build_ldap" --source_id="ldap"
mkdir -p "$install_dir/live/data"
mkdir -p "$install_dir/live_ldap/data"
cp -r "$install_dir/build/static/" "$install_dir/live/"
ynh_replace_string --match_string="<div class=\"galene-header\">Galène</div>" --replace_string="<div class=\"galene-header\" onclick=\"location.href=window.location.origin\" style=\"cursor:pointer\">Galène</div>" --target_file="$install_dir/live/static/galene.html"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Building app..." --weight=1
ynh_exec_warn_less ynh_install_go --go_version=$go_version
ynh_use_go
pushd $install_dir/build/
ynh_exec_warn_less ynh_exec_as $app CGO_ENABLED=0 $ynh_go build -ldflags='-s -w' -o $install_dir/live/
popd
pushd $install_dir/build_ldap/
ynh_exec_warn_less ynh_exec_as $app CGO_ENABLED=0 $ynh_go build -ldflags='-s -w' -o $install_dir/live_ldap/
popd
ynh_remove_go
ynh_secure_remove --file="$install_dir/build/"
ynh_secure_remove --file="$install_dir/build_ldap/"
ynh_secure_remove --file="$install_dir/.cache/"
ynh_secure_remove --file="$install_dir/go/"
ynh_secure_remove --file="$install_dir/.go-version"
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1
mkdir -p $data_dir/{groups,recordings}
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$data_dir"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
# Configure Galène
ynh_add_config --template="../conf/config.json" --destination="$install_dir/live/data/config.json"
chmod 400 "$install_dir/live/data/config.json"
chown $app:$app "$install_dir/live/data/config.json"
# Configure Galène LDAP
key=$(jose jwk gen -i '{"kty":"oct","alg":"HS256"}')
ynh_app_setting_set --app=$app --key=key --value="$key"
ynh_add_config --template="../conf/galene-ldap.json" --destination="$install_dir/live_ldap/data/galene-ldap.json"
chmod 400 "$install_dir/live_ldap/data/galene-ldap.json"
chown $app:$app "$install_dir/live_ldap/data/galene-ldap.json"
# Create a group name config
ynh_add_config --template="../conf/groupname.json" --destination="$data_dir/groups/$group_name.json"
chmod 400 "$data_dir/groups/$group_name.json"
chown $app:$app "$data_dir/groups/$group_name.json"
# Create a group name authenticated on LDAP
ynh_add_config --template="../conf/groupname-ldap.json" --destination="$data_dir/groups/YunoHost_Users.json"
chmod 400 "$data_dir/groups/YunoHost_Users.json"
chown $app:$app "$data_dir/groups/YunoHost_Users.json"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
public_ip4="$(curl -s ip.yunohost.org)" || true
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_add_systemd_config --service=${app}_ldap --template="ldap.service"
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
yunohost service add $app --description="Videoconferencing server" --needs_exposed_ports="$port_turn"
yunohost service add ${app}_ldap --description="LDAP integration for the videoconferencing server"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
ynh_systemd_action --service_name=${app}_ldap --action="start" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last