1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cac-proxy_ynh.git synced 2024-09-03 18:16:07 +02:00

Reworked install with chromium support

This commit is contained in:
Gérard Collin 2023-02-26 15:36:39 +01:00
parent 7cf7fca65c
commit adaea1401d
6 changed files with 49 additions and 6 deletions

View file

@ -6,6 +6,7 @@
domain="domain.tld"
path="/path"
is_public=0
install_chromium=1
; Checks
pkg_linter=1
setup_sub_dir=1

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/gcollin/cookie-aware-cors-proxy/releases/download/v1.1.0/cookie-aware-cors-proxy.tgz
SOURCE_SUM=473df2664fe560b525a8a4d4d9edd4ffefa544dabfd37a25e199f2a37270a6e0
SOURCE_URL=https://github.com/gcollin/cookie-aware-cors-proxy/releases/download/v1.1.4/cookie-aware-cors-proxy.tgz
SOURCE_SUM=c56ca989233d4d2f3a2304ec96d979445f97232c8be63d5910d819af66f83ab9
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

View file

@ -7,7 +7,7 @@ Type=simple
User=__APP__
Group=__APP__
EnvironmentFile=__FINALPATH__/.env
WorkingDirectory=__FINALPATH__/
WorkingDirectory=__FINALPATH__/package/
ExecStart=__YNH_NODE__ ./src/server.js
StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit

View file

@ -36,6 +36,16 @@
"example": "/proxy",
"default": "/proxy"
},
{
"name": "install_chromium",
"type": "boolean",
"default": false,
"optional": true,
"ask": {
"en": "Install Chromium for advanced website support (+480 MB).",
"fr": "Installer Chromium pour supporter les sites web complexes (+480 MB)."
}
},
{
"name": "public_key",
"type": "string",

View file

@ -27,6 +27,7 @@ domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
public_key=$YNH_APP_ARG_PUBLIC_KEY
is_public=$YNH_APP_ARG_IS_PUBLIC
install_chromium=$YNH_APP_ARG_INSTALL_CHROMIUM
### If it's a multi-instance app, meaning it can be installed several times independently
### The id of the app as stated in the manifest is available as $YNH_APP_ID
@ -74,6 +75,7 @@ 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=path --value=$path_url
ynh_app_setting_set --app=$app --key=install_chromium --value=$install_chromium
#=================================================
# STANDARD MODIFICATIONS
@ -135,7 +137,8 @@ ynh_script_progression --message="Setting up source files..." --weight=6
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from amd64.src
ynh_setup_source --source_id=amd64 --dest_dir="$final_path"
mkdir --parents $final_path/package
ynh_setup_source --source_id=amd64 --dest_dir="$final_path/package"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
@ -170,6 +173,19 @@ then
fi
#=================================================
# Install chromium
#=================================================
if [ $install_chromium -eq 1 ]
then
ynh_script_progression --message="Installing Chromium..." --weight=8
cd "$final_path/package"
ynh_exec_as $app $ynh_node_load_PATH $ynh_node "./node_modules/puppeteer/install.js"
cd -
fi
#=================================================
# NGINX CONFIGURATION
#=================================================

View file

@ -21,6 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
public_key=$(ynh_app_setting_get --app=$app --key=public_key)
install_chromium=$(ynh_app_setting_get --app=$app --key=install_chromium)
#=================================================
# CHECK VERSION
@ -101,7 +102,7 @@ fi
complete_install=false
# Check if we need to clean up old bad installs
if [ -f "$final_path/" ]; then
if [ -f "$final_path/package.json" ]; then
complete_install=true
rm -rf "$final_path/*"
fi
@ -114,7 +115,8 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=6
# Download, check integrity, uncompress and patch the source from amd64.src
ynh_setup_source --source_id=amd64 --dest_dir="$final_path"
mkdir --parents $final_path/package
ynh_setup_source --source_id=amd64 --dest_dir="$final_path/package"
fi
@ -157,6 +159,20 @@ then
fi
#=================================================
# Install chromium
#=================================================
if [ $install_chromium -eq 1 ]
then
ynh_script_progression --message="Upgrading Chromium..." --weight=8
# Remove old versions of chrome
ynh_secure_remove --file="$final_path/.cache/puppeteer/chrome"
# And install the latest one
cd "$final_path/package"
ynh_exec_as $app $ynh_node_load_PATH $ynh_node "./node_modules/puppeteer/install.js"
fi
#=================================================
# NGINX CONFIGURATION
#=================================================