I'm an avid torrenter, and since I'm busy must of the day, having Transmission-GTK run at night is my best option. However, my college server loves to kick people out after either an extended time limit or a download limit on wifi. I needed automation while I was sleeping.
Using Java-GTK and Bash, created a application that brings up a window asking for which VPN to use. It stores the output in a variable and connects it. Then, if the connection was a success it started up transmission.
Now, Ive set up a script that pings 188.8.131.52 every hour on the hour, if it failed, it pings my school network. If that failed kills transmission, then it restarts the network using
sudo service network-manager restart. Then reconnects the VPN, and finally restarts transmission. (I know that I can use
start but I choose not to). Upon usage, I face-palmed and realized that sudo needed my password as the admin.
I've researched this for nearly a week, looking for some way to give a script root privileges, and I have seen hundreds of warnings and "sudo is the way" comments. I've looked into the sudoers file, tried it, and it hasn't worked (it still prompts for a password for the most basic configurations). I've also looked into creating a C binary telling a script to run with 0 uid, setting that C binary to chmod and chown root permissions. To no avail. (I have not tried daemons as I know very little of C.) (Mostly Bash, and a bit of Java).
Perhaps a script/configuration in /etc/network folder? I don't mind answers that work outside of my original script framework, as security precautions prevent scripts from being rooted.
PS. I'm not looking for warnings as answers, but answers with warnings.