2021-03-29 16:24:15 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# COMMON VARIABLES
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# dependencies used by the app
|
2021-03-31 21:54:24 +02:00
|
|
|
pkg_dependencies="nodejs npm libpng16-16 libpng-dev pkg-config autoconf libtool build-essential nasm libx11-dev libxkbfile-dev"
|
2021-03-29 16:24:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PERSONAL HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2021-04-18 23:07:30 +02:00
|
|
|
function set_node_vars {
|
2022-01-02 18:45:04 +01:00
|
|
|
nodejs_version=$(ynh_app_setting_get --app=$app --key=nodejs_version)
|
2022-06-18 18:08:37 +02:00
|
|
|
if [ "$nodejs_version" -ne 16 ]; then
|
2022-01-02 18:45:04 +01:00
|
|
|
ynh_exec_warn_less ynh_remove_nodejs
|
|
|
|
fi
|
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=16
|
2021-04-18 03:32:11 +02:00
|
|
|
ynh_use_nodejs
|
2021-04-27 22:56:53 +02:00
|
|
|
node_path="$nodejs_path:$(sudo -u $app sh -c 'echo $PATH')"
|
2021-04-18 23:07:30 +02:00
|
|
|
}
|
2021-04-18 03:32:11 +02:00
|
|
|
|
2021-04-18 23:07:30 +02:00
|
|
|
function build_node_app {
|
|
|
|
set_node_vars
|
2021-04-27 22:56:53 +02:00
|
|
|
|
2021-04-28 01:49:44 +02:00
|
|
|
grep -v electron "$final_path/package.json" > "$final_path/server-package.json"
|
|
|
|
mv "$final_path/server-package.json" "$final_path/package.json"
|
2021-04-27 22:56:53 +02:00
|
|
|
pushd "$final_path"
|
|
|
|
chown -R $app:$app "$final_path"
|
|
|
|
sudo -u $app touch "$final_path/.yarnrc"
|
2022-01-02 18:45:04 +01:00
|
|
|
sudo -u $app env "PATH=$node_path" yarn --cache-folder "$final_path/yarn-cache" --use-yarnrc "$final_path/.yarnrc" import 2>&1
|
2021-04-28 01:49:44 +02:00
|
|
|
sudo -u $app env "PATH=$node_path" yarn --cache-folder "$final_path/yarn-cache" --use-yarnrc "$final_path/.yarnrc" install --production 2>&1
|
2021-04-27 22:56:53 +02:00
|
|
|
chown -R root:root "$final_path"
|
|
|
|
popd
|
|
|
|
|
|
|
|
set_permissions
|
2021-04-18 03:32:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_permissions {
|
2021-04-27 22:56:53 +02:00
|
|
|
chown -R root:$app "$final_path"
|
|
|
|
chmod -R g=u,g-w,o-rwx "$final_path"
|
|
|
|
chown -R $app:$app "$data_path"
|
|
|
|
chmod -R g=u,g-w,o-rwx "$data_path"
|
2021-04-18 03:32:11 +02:00
|
|
|
}
|
|
|
|
|
2022-01-03 17:54:48 +01:00
|
|
|
function setup_sources {
|
|
|
|
ynh_secure_remove "$final_path"
|
|
|
|
ynh_setup_source --dest_dir="$final_path"
|
|
|
|
mkdir -p "$data_path"
|
|
|
|
}
|
|
|
|
|
2021-03-29 16:24:15 +02:00
|
|
|
#=================================================
|
|
|
|
# EXPERIMENTAL HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# FUTURE OFFICIAL HELPERS
|
|
|
|
#=================================================
|