Giter Site home page Giter Site logo

shinit's Introduction

shinit

Basic init daemon in POSIX sh with only 5 lines of code. It supports acting upon signals.

On USR1 signal it will poweroff, and on INT signal it will reboot.

Installing

Before installing, edit the second command to use your boot/poweroff script. If you are using Carbs Linux or KISS, you don't need to change it.

You can then install with make.

make install

Note on halting the system

shinit does NOT deal with system halting. You will need an extra utility for that given purpose. ubase halt deals with this. You can also use compile this really simple C program that tells to kernel to shutdown or reboot.

#include <sys/reboot.h>

int
main(int argc, char *argv[])
{
    switch ((int) argv[argc < 2 ? 0 : 1][0]) {
    case 'p': reboot(RB_POWER_OFF); break;
    case 'r': reboot(RB_AUTOBOOT);  break;
    default: return 1;
    }
    return 0;
}

You can compile the following program to something named halt or whatever you like. If you call halt p it will power off, if you call halt r it will reboot. Just note that this needs to be at the end of your init script, because this command will shut your computer down straight away. You can do the following check at the end of your init script:

case "$1" in
    poweroff) halt p ;;
    reboot)   halt r ;;
esac

shinit's People

Contributors

cemkeylan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dagelf

shinit's Issues

Why not wait'ing?

Why not replacing the sleep with wait? One cannot know how long will a user have its computer on (I, for instance, usually keep it on for more than a day). wait will wait (what a surprise ๐Ÿ˜…) until all spawned processes finish.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.