aps/altools/c/pow.c

29 lines
539 B
C
Raw Normal View History

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/reboot.h>
int main (int argc, char *argv[]) {
if (geteuid() != 0) {
printf("[E] pow must be run as root\n");
return 1;
}
sync();
switch (argv[1] ? argv[1][0]: 0) {
case 's':
case 'p':
reboot(RB_POWER_OFF);
return 0;
case 'r':
reboot(RB_AUTOBOOT);
return 0;
default:
printf("pow r[eboot]|p[oweroff]|s[hutdown]\n");
return 1;
}
}