I have a Java application that starts automatically when the headless machine (Ubuntu 14.04 Server) boots and runs as a user. When the application is finished I need it to execute a script to poweroff because an external breaker is about to be thrown which will cut the power.
I cannot allow to hang if it detects shutdown errors at the next boot.
My attempts to write a script all result in a request for the super-user's password. I can accept the password be present in text in a script as the machine is isolated from the internet.
I'm not proficient in bash or Linux.
$ ls -la shutdown -rwsr-xr-x 1 root root 209 Mar 18 16:55 shutdown