06bba6f68f
0.1.0 is a complete rewrite @hippoz, @hippoz it is supposed to clean up aps. :trol:
28 lines
539 B
C
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;
|
|
}
|
|
}
|