@hippie
Thank you for your contribution on systemd on Raspbian Jessie.
I could not do the usual automatic startup at boot after installing Jessie from Wheezy. The normal crontab -e @boot /home/user21/ovpns/pi_openvpn_server did not work anymore. I tried /etc/init.d and systemd, but to no avail.
All I need was a very simple entry point to launch a shell script at boot. I tried the codes from hippie, and viola, it did solved my pressing problem.
I am re-writing something very similar to hippie for the benefit to all Jessie Raspbian users.
STEP 1:
sudo nano /etc/systemd/system/pi_openvpn_server.service
[Unit]
Description=Raspberry PI OpenVPN Server
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/home/user21/ovpns/pi_openvpn_server
ExecReload=/home/user21/ovpns/pi_openvpn_server
WorkingDirectory=/home/user21/ovpns
[Install]
WantedBy=multi-user.target
STEP 2: (Both korn and bash shell work for openvpn_server_script)
sudo nano /home/user21/ovpns/pi_openvpn_server
#!/bin/sh -e
. /home/user21/ovpns/openvpn_server_script
exit 0
STEP 3:
It may be necessary to comment out the line, local 192.168.71.123, in openvpn_svr.conf, or the systemd could fail.
sudo nano /home/user21/ovpns/openvpn_svr.conf
;##local 192.168.71.123
dev tun
proto tcp
port 443
tun-ipv6
push tun-ipv6
STEP 4:
sudo systemctl enable pi_openvpn_server.service
sudo systemctl daemon-reload
sudo reboot
EXTRA:
Run the following two commands whenever editing and changes to the files were done.
sudo systemctl daemon-reload
sudo reboot
The above, work for me unexpected as I initially had the impression that systemd could be complicated to setup with the start, stop, reload at the bottom of the file, with the do_start, do_stop and do_reload functions in the middle and setting the system environment at the top. Also, it could be daunting to learn and to know how the systemd commands behave. As hippie has correctly pointed out, a simple stub to launch any korn or bash shell script is needed in systemd.
As for OpenVPN, Jessie is a major improvement over Wheezy. The OpenVPN 2.3.4 and OpenSSL 1.0.1k is required for the major security improvements. Until a few days ago, I had failed to install Fedora 22 onto Raspberry PI 2 many times. Now, I do not need to look into other Linux distributions for PI. Jessie is the trusted one with strong support from Raspbain and Debian. Thank you to the Raspberry Foundation team in porting Jessie onto the Raspberry PI.
AlKD
Malaysia