Fixed root check and targeted POSIX shell instead of Bash.

main
Andrew Klapp 7 years ago
parent 8d579fed16
commit f3b57b0ac1
No known key found for this signature in database
GPG Key ID: D78ADB07F66B6AE4

@ -16,5 +16,5 @@ anonymous.
service. service.
## Usage ## Usage
Just run `openvpn-rotate` and it will link a random configuration to the path that Just run `openvpn-rotate` and it will link a random different configuration to the path that
`openvpn.service` reads. It does not currently accept any arguments. `openvpn.service` reads. It does not currently accept any arguments.

@ -1,13 +1,11 @@
#!/usr/bin/env bash #!/bin/sh
ovpn_directory="/etc/openvpn/client/ovpn-enabled" ovpn_directory="/etc/openvpn/client/ovpn-enabled"
current_ovpn_path="/etc/openvpn/client/current.ovpn" current_ovpn_path="/etc/openvpn/client/current.ovpn"
# TODO: Investigate better ways to check for rootness. This is just a courtesy message, though. if [ "$(id -u)" -ne 0 ]; then
# Non-root users will not be able to do anything with this anyway.
if [ "$(whoami)" != "root" ]; then
echo "This script needs root privileges to interact with the openvpn service." echo "This script needs root privileges to interact with the openvpn service."
exit exit 1
fi fi
prior_ovpn_path="$(readlink "${current_ovpn_path}")" prior_ovpn_path="$(readlink "${current_ovpn_path}")"

Loading…
Cancel
Save