diff --git a/conf/sysctl.conf b/conf/sysctl.conf new file mode 100644 index 0000000..f501eb9 --- /dev/null +++ b/conf/sysctl.conf @@ -0,0 +1,2 @@ +net.ipv4.ip_forward = 1 +net.ipv6.conf.all.forwarding = 1 diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 3ea978a..fae5ecf 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,22 +1,8 @@ * WireGuard for YunoHost will add a DMKS module to your Linux kernel. * You may need to reboot your server for WireGuard to be able to start. * The package includes WireGuard and non-official web UI to configure it. - * Avoid altering the configuration files via the command line interface, though. + * Do not manually alter the configuration files. * Use YunoHost permissions panel to allow users to access the web UI. * Only one network interface, *wg0*, can be managed with this app at the moment. After installation, you need to `Apply Config` once in the UI before the VPN service can be started. - -### Make your server share its Internet connection - -#### Enable port forwarding - -```bash -sudo nano /etc/sysctl.conf -# Uncomment the following lines: -net.ipv4.ip_forward = 1 -net.ipv6.conf.all.forwarding = 1 -# Save and quit (CTRL+O, CTRL+X) -sudo sysctl -p -``` - diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md index b6d5bf9..e4667ce 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -1,22 +1,8 @@ * Cette application ajoutera un module DMKS à votre noyau Linux. * Vous devriez redémarrer votre serveur pour que WireGuard puisse se lancer. * Cette application inclut WireGuard et une interface web non-officielle pour le configurer. - * Évitez de modifier les fichiers de configuration via la ligne de commande. + * Ne modifiez pas les fichiers de configuration à la main. * Utiliser le panneau de permissions de YunoHost pour autoriser des utilisateurs à accéder à WireGuard UI. * Une seule interface réseau, *wg0*, peut actuellement être gérée par cette app. Après installation, vous devrez cliquer sur `Apply Config` une fois dans l'UI avant que le service VPN puisse être démarré. - -### Partagez votre connexion Internet via WireGuard - -#### Activez le *port forwarding* - -```bash -sudo nano /etc/sysctl.conf -# Décommentez les lignes suivantes : -net.ipv4.ip_forward = 1 -net.ipv6.conf.all.forwarding = 1 -# Sauvegardez et quittez (CTRL+O, CTRL+X) -sudo sysctl -p -``` - diff --git a/scripts/backup b/scripts/backup index 7549c0a..0e9ebff 100644 --- a/scripts/backup +++ b/scripts/backup @@ -68,6 +68,9 @@ ynh_backup --src_path="/etc/wireguard" # Backing up specific config file, in case of it is not in /etc/wireguard ynh_backup --src_path="$(jq -r ".config_file_path" $final_path/db/server/global_settings.json)" --not_mandatory +# Backup the sysctl config file to enable port forwarding +ynh_backup --src_path="/etc/sysctl.d/$app.conf" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index f1c9abe..8aa2e1f 100644 --- a/scripts/install +++ b/scripts/install @@ -149,6 +149,14 @@ systemctl daemon-reload systemctl enable --quiet wireguard@wg0.service systemctl enable --quiet --now wireguard@wg0.path +#================================================= +# ENABLE PORT FORWARDING +#================================================= +ynh_script_progression --message="Enabling port forwarding..." --weight=1 + +ynh_add_config --template="../conf/sysctl.conf" --destination="/etc/sysctl.d/$app.conf" +sysctl -p /etc/sysctl.d/$app.conf + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/remove b/scripts/remove index d974789..3c35861 100644 --- a/scripts/remove +++ b/scripts/remove @@ -111,6 +111,9 @@ fi # Remove sudoers file ynh_secure_remove --file="/etc/sudoers.d/${app}_ynh" +# Remove sysctl file for port forwarding +ynh_secure_remove --file="/etc/sysctl.d/$app.conf" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 93d17fb..e66d9da 100644 --- a/scripts/restore +++ b/scripts/restore @@ -119,6 +119,14 @@ systemctl enable --quiet wireguard_ui.service systemctl enable --quiet wireguard@wg0.service systemctl enable --quiet --now wireguard@wg0.path +#================================================= +# ENABLE PORT FORWARDING +#================================================= +ynh_script_progression --message="Enabling port forwarding..." --weight=1 + +ynh_restore_file --origin_path="/etc/sysctl.d/$app.conf" +sysctl -p /etc/sysctl.d/$app.conf + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 1071be5..635c5bc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -186,8 +186,12 @@ systemctl enable --quiet wireguard@wg0.service systemctl enable --quiet --now wireguard@wg0.path #================================================= -# CONFIGURING WIREGUARD +# ENABLE PORT FORWARDING #================================================= +ynh_script_progression --message="Enabling port forwarding..." --weight=1 + +ynh_add_config --template="../conf/sysctl.conf" --destination="/etc/sysctl.d/$app.conf" +sysctl -p /etc/sysctl.d/$app.conf #================================================= # GENERIC FINALIZATION