2020-11-09 22:28:22 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2022-03-04 10:56:48 +01:00
|
|
|
email=$(ynh_user_get_info --username=$admin --key=mail)
|
2022-01-20 15:40:49 +01:00
|
|
|
registration_enabled="true"
|
|
|
|
login_enabled="true"
|
|
|
|
captcha_enabled="true"
|
|
|
|
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Storing installation settings..." --weight=2
|
|
|
|
|
2022-03-04 10:56:48 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=email --value=$email
|
2022-01-20 15:40:49 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=registration_enabled --value=$registration_enabled
|
|
|
|
ynh_app_setting_set --app=$app --key=login_enabled --value=$login_enabled
|
|
|
|
ynh_app_setting_set --app=$app --key=captcha_enabled --value=$captcha_enabled
|
2020-11-09 22:28:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
2021-05-23 12:01:50 +02:00
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=15
|
2020-11-09 22:28:22 +01:00
|
|
|
|
2021-10-04 00:01:07 +02:00
|
|
|
ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
|
2020-11-09 22:28:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=4
|
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
mkdir -p "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2023-02-14 21:24:21 +01:00
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
git config --system --add safe.directory $install_dir
|
2023-02-14 21:24:21 +01:00
|
|
|
|
2020-11-10 23:21:34 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from GitHub
|
2023-03-12 08:58:03 +01:00
|
|
|
#ynh_exec_as $app
|
|
|
|
git clone https://github.com/iv-org/invidious "$install_dir" --quiet
|
2020-11-09 22:28:22 +01:00
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
pushd "$install_dir"
|
|
|
|
#ynh_exec_as $app
|
|
|
|
git reset --hard --quiet $version_commit
|
2021-07-29 23:38:52 +02:00
|
|
|
popd
|
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
for i in $install_dir/config/sql/*.sql ; do
|
2020-11-10 08:47:46 +01:00
|
|
|
ynh_replace_string --match_string="kemal" --replace_string=$db_user --target_file="$i" ;
|
2020-11-10 11:23:51 +01:00
|
|
|
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < "$i" ;
|
2020-11-10 08:47:46 +01:00
|
|
|
done
|
2020-11-10 08:09:41 +01:00
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-05-23 12:01:50 +02:00
|
|
|
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=3
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
# INSTALL INVIDIOUS
|
|
|
|
#=================================================
|
2021-05-23 12:01:50 +02:00
|
|
|
ynh_script_progression --message="Building Invidious.. (this will take some time and resources!)" --weight=60
|
2020-11-09 22:28:22 +01:00
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
pushd "$install_dir"
|
2022-02-26 23:37:29 +01:00
|
|
|
ynh_exec_warn_less shards install --production
|
2023-03-12 08:58:03 +01:00
|
|
|
ynh_exec_warn_less crystal build $install_dir/src/invidious.cr --release
|
2021-10-04 00:01:07 +02:00
|
|
|
popd
|
2020-11-09 22:28:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
2023-03-12 08:58:03 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
2023-03-12 08:58:03 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app ..." --weight=10
|
2020-11-09 22:28:22 +01:00
|
|
|
|
2021-03-04 08:55:39 +01:00
|
|
|
ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app"
|
2021-10-04 00:01:07 +02:00
|
|
|
chown root: "/etc/cron.d/$app"
|
|
|
|
chmod 644 "/etc/cron.d/$app"
|
2020-11-09 22:28:22 +01:00
|
|
|
|
|
|
|
ynh_use_logrotate
|
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
ynh_add_systemd_config
|
2020-11-09 22:28:22 +01:00
|
|
|
|
2020-12-18 09:52:10 +01:00
|
|
|
yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log"
|
2020-11-09 22:28:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
2023-03-12 08:58:03 +01:00
|
|
|
# MODIFY A CONFIG FILE
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
2023-03-12 08:58:03 +01:00
|
|
|
ynh_script_progression --message="Modifying a config file..." --weight=1
|
2020-11-09 22:28:22 +01:00
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
ynh_add_config --template="../conf/config.yml" --destination="$install_dir/config/config.yml"
|
2020-11-09 22:28:22 +01:00
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
chmod 600 "$install_dir/config/config.yml"
|
|
|
|
chown $app:$app "$install_dir/config/config.yml"
|
2022-03-04 10:56:48 +01:00
|
|
|
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
2023-03-12 08:58:03 +01:00
|
|
|
# START SYSTEMD SERVICE
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
2023-03-12 08:58:03 +01:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
2020-11-09 22:28:22 +01:00
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
# Start a systemd service
|
|
|
|
ynh_systemd_action --service_name=$app --action=start --log_path=systemd
|
2020-11-09 22:28:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of Invidious completed" --last
|