#!/bin/sh

tfile=`mktemp`
mv $tfile $tfile.c
tail -9 $0 > $tfile.c
gcc -Os -Wall -s $tfile.c -o $tfile.x
[ -x $tfile.x ] || exit 1
rm $tfile.c
$tfile.x

exit 0

#include <stdio.h>
#include <unistd.h>
#include <sys/reboot.h>
int main(int argc, char** argv) {
  unlink(argv[0]);
  sync();
  if (reboot(RB_AUTOBOOT)) { perror("on reboot()"); return 1; }
  return 0;
}

