mirror of
https://github.com/YunoHost-Apps/jellyfin_ynh.git
synced 2024-09-03 19:26:29 +02:00
Use firewall helper
This commit is contained in:
parent
8234907aed
commit
23d821d0ec
6 changed files with 70 additions and 48 deletions
|
@ -146,5 +146,12 @@ ram.runtime = "100M"
|
||||||
|
|
||||||
[resources.ports]
|
[resources.ports]
|
||||||
main.default = 8095
|
main.default = 8095
|
||||||
|
# If we ever want to automatically expose the discovery ports without a setting
|
||||||
|
# servicediscovery.default = 1900
|
||||||
|
# servicediscovery.exposed = "UDP"
|
||||||
|
# servicediscovery.fixed = true
|
||||||
|
# clientdiscovery.default = 7359
|
||||||
|
# clientdiscovery.exposed = "UDP"
|
||||||
|
# clientdiscovery.fixed = true
|
||||||
|
|
||||||
[resources.apt]
|
[resources.apt]
|
||||||
|
|
|
@ -65,11 +65,39 @@ install_jellyfin_packages() {
|
||||||
apt-mark auto jellyfin-server jellyfin-web jellyfin-ffmpeg6
|
apt-mark auto jellyfin-server jellyfin-web jellyfin-ffmpeg6
|
||||||
}
|
}
|
||||||
|
|
||||||
open_jellyfin_discovery_ports() {
|
configure_jellyfin_discovery_ports() {
|
||||||
|
case $1 in
|
||||||
|
"install")
|
||||||
|
install_jellyfin_discovery_ports
|
||||||
|
;;
|
||||||
|
"remove")
|
||||||
|
remove_jellyfin_discovery_ports
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ynh_print_warn --message="Invalid script calling configure_jellyfin_discovery_ports with args (should be install|remove): $@"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_jellyfin_discovery_ports() {
|
||||||
|
if [[ $discovery_service -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_service_port$"
|
||||||
|
then
|
||||||
|
ynh_exec_warn_less yunohost firewall disallow UDP $discovery_service_port
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $discovery_client -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_client_port$"
|
||||||
|
then
|
||||||
|
ynh_exec_warn_less yunohost firewall disallow UDP $discovery_client_port
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
install_jellyfin_discovery_ports() {
|
||||||
discovery_service=$discovery
|
discovery_service=$discovery
|
||||||
discovery_client=$discovery
|
discovery_client=$discovery
|
||||||
|
|
||||||
if [ "$discovery" -eq 1 ]; then
|
if [ "$discovery" -eq 1 ]; then
|
||||||
|
opened_ports=($discovery_service_port $discovery_client_port)
|
||||||
|
|
||||||
# Open port $discovery_service_port for service auto-discovery
|
# Open port $discovery_service_port for service auto-discovery
|
||||||
if ynh_port_available --port=$discovery_service_port; then
|
if ynh_port_available --port=$discovery_service_port; then
|
||||||
|
|
|
@ -23,10 +23,8 @@ ynh_app_setting_set --app="$app" --key=config_path --value="$config_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# OPEN PORTS
|
# OPEN PORTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Checking whether to open ports..." --weight=1
|
||||||
ynh_script_progression --message="Configuring firewall..." --weight=1
|
configure_jellyfin_discovery_ports install
|
||||||
|
|
||||||
open_jellyfin_discovery_ports
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL PACKAGES
|
# INSTALL PACKAGES
|
||||||
|
@ -107,7 +105,13 @@ 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="Jellyfin media center"
|
ports_args=()
|
||||||
|
if [[ "${opened_ports:-__NOTHING__}" = "__NOTHING__" ]]; then
|
||||||
|
ports_args+=('--open-ports')
|
||||||
|
ports_args+=(${ports})
|
||||||
|
fi
|
||||||
|
|
||||||
|
yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}"
|
||||||
|
|
||||||
# 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="admin" --add="$admin"
|
ynh_permission_update --permission="admin" --add="$admin"
|
||||||
|
|
|
@ -41,18 +41,8 @@ ynh_remove_app_dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLOSE A PORT
|
# CLOSE A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Checking whether to open ports..." --weight=1
|
||||||
if [[ $discovery_service -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_service_port$"
|
configure_jellyfin_discovery_ports remove
|
||||||
then
|
|
||||||
ynh_script_progression --message="Closing port $discovery_service_port..." --weight=1
|
|
||||||
ynh_exec_warn_less yunohost firewall disallow UDP $discovery_service_port
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $discovery_client -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_client_port$"
|
|
||||||
then
|
|
||||||
ynh_script_progression --message="Closing port $discovery_client_port..." --weight=1
|
|
||||||
ynh_exec_warn_less yunohost firewall disallow UDP $discovery_client_port
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# SPECIFIC REMOVE
|
||||||
|
|
|
@ -27,9 +27,8 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# OPEN PORTS
|
# OPEN PORTS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring firewall..." --weight=1
|
ynh_script_progression --message="Checking whether to open ports..." --weight=1
|
||||||
|
configure_jellyfin_discovery_ports install
|
||||||
open_jellyfin_discovery_ports
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
|
@ -93,7 +92,15 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
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="Jellyfin media center"
|
ports_args=()
|
||||||
|
if [[ "${opened_ports:-__NOTHING__}" = "__NOTHING__" ]]; then
|
||||||
|
ports_args+=('--open-ports')
|
||||||
|
ports_args+=(${ports})
|
||||||
|
fi
|
||||||
|
|
||||||
|
yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
|
|
|
@ -55,31 +55,11 @@ if [ ! -f "/etc/logrotate.d/$app" ]; then
|
||||||
ynh_use_logrotate
|
ynh_use_logrotate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
discovery_service=$discovery
|
#=================================================
|
||||||
discovery_client=$discovery
|
# OPEN PORTS
|
||||||
|
#=================================================
|
||||||
if [ $discovery -eq 1 ]; then
|
ynh_script_progression --message="Checking whether to open ports..." --weight=1
|
||||||
ynh_script_progression --message="Configuring firewall..." --weight=1
|
configure_jellyfin_discovery_ports install
|
||||||
|
|
||||||
# Open port $discovery_service_port for service auto-discovery
|
|
||||||
if ynh_port_available --port=$discovery_service_port; then
|
|
||||||
ynh_exec_warn_less yunohost firewall allow UDP $discovery_service_port
|
|
||||||
else
|
|
||||||
discovery_service=0
|
|
||||||
ynh_print_warn --message="Port $discovery_service_port (for service auto-discovery) is not available. Continuing nonetheless."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Open port $discovery_client_port for client auto-discovery
|
|
||||||
if ynh_port_available --port=$discovery_client_port; then
|
|
||||||
ynh_exec_warn_less yunohost firewall allow UDP $discovery_client_port
|
|
||||||
else
|
|
||||||
discovery_client=0
|
|
||||||
ynh_print_warn --message="Port $discovery_client_port (for client auto-discovery) is not available. Continuing nonetheless."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=discovery_service --value=$discovery_service
|
|
||||||
ynh_app_setting_set --app=$app --key=discovery_client --value=$discovery_client
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE PACKAGES
|
# UPGRADE PACKAGES
|
||||||
|
@ -189,7 +169,13 @@ 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="Jellyfin media center"
|
ports_args=()
|
||||||
|
if [[ "${opened_ports:-__NOTHING__}" = "__NOTHING__" ]]; then
|
||||||
|
ports_args+=('--open-ports')
|
||||||
|
ports_args+=(${ports})
|
||||||
|
fi
|
||||||
|
|
||||||
|
yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EDIT SYSTEMD ENVIRONMENT VARIABLE FOR AUTO-DISCOVERY
|
# EDIT SYSTEMD ENVIRONMENT VARIABLE FOR AUTO-DISCOVERY
|
||||||
|
|
Loading…
Add table
Reference in a new issue