aps/altools/c/pow.c
Ohio2 06bba6f68f 0.1.0 BETA
0.1.0 is a complete rewrite @hippoz, @hippoz it is supposed to clean up
  aps. :trol:
2021-09-29 15:48:11 +02:00

28 lines
539 B
C

#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;
}
}