- Go 56.5%
- Shell 40.8%
- Makefile 2.7%
| init | TEMPLATES :D | |
| rc | restructured | |
| rc-exec | change default from -1 to 20 in rc-exec | |
| rc-helper | restructured | |
| LICENSE | Initial commit | |
| README.md | TEMPLATES :D | |
jackson | v0.2.4
A experimental custom init system, minimal and extendable. Named after my cat Jackson. I highly advise you read the Building and Docs/Usage section.
Building
init
This is the jackson init.
You can configure some stuff in config.go, but everything I provide assumes the defaults for the init (except rc-exec because it doesnt directly interact with the init).
To build the init cd into the init/ directory then run:
make
And to install:
make install
It will not work unless /etc/rc.core, /etc/rc.list, /etc/rc.shutdown, /etc/rc.reboot are files and /etc/rc.services is a directory.
There are a set of default scripts you could use (see default scripts below).
See the docs on why and how to use.
rc-helper
rc-helper is a script to help manage services and interact with the init.
To install the rc-helper script cd into the rc-helper/ directory and run:
make install
It is quite simple at the moment but Ill make it more complex later on. See docs on how to use.
rc-exec
rc-exec is a tool for auto-restarting programs/commands if they die unexpectedly. The default scripts need it.
You can configure some stuff in config.go.
To build the rc-exec service helper cd to rc-exec/ and run:
make
Then to install:
make install
It is a tool that the default services use. See docs on how to use.
default scripts
These are a set of default scripts and services.
To install cd into the rc/ directory and run:
make install
This installs a default rc.core, rc.list, rc.shutdown, rc.reboot and a set of scripts found in rc.services.
You may want to edit rc.list before installing or edit /etc/rc.list after installing because its by default setup for Alpine Linux.
Docs/Usage
init
It doesnt depend on anything but /etc/rc.list, /etc/rc.core, /etc/rc.shutdown, /etc/rc.reboot as files and /etc/rc.services as a directory.
How to make a script
Its very simple. Simply make a sysv init like script like so:
#!/bin/sh
_start() {
# Do something to start
}
_stop() {
# Do something to stop
}
case 1ドル in
start) _start ;;
stop) _stop ;;
esac
If you install rc-exec you can use it when starting to make something that will automaticly restart the command if it fails/crashes.
It its a template you will be passed a 2,ドル you could handle it like so:
#!/bin/sh
_start() {
# Do something to start
}
_stop() {
# Do something to stop
}
case 1ドル in
start) _start "2ドル" ;;
stop) _stop "2ドル" ;;
esac
how it works
rc.core, rc.list
rc.core is like a script in structure.
You should put the stuff to happen on boot and when the system is powering off.
rc.list has services started from top to bottom on boot after rc.core.
On shutdown/reboot it is done in reverse order before rc.core.
The init calls /etc/rc.services/<service> for each line in rc.list.
It will skip any line starting with # or blank lines.
Templates are called with foo(bar), foo being the template and bar is passed as 2ドル to template foo
rc.list should look like:
# example comment
service1
service2
#commented-out-service
template(arg2)
#whitespace is also supported in templates, but no () can be inside the arg2
template2(this is valid)
rc.shutdown, rc.reboot
They are not like a service but just a script dictating what to do to shutdown or reboot.
It is ran after the services and rc.core.
rc.shutdown is ran on shutdown or when the init gets SIGUSR1.
rc.reboot is ran on reboot or when the init gets SIGINT.
rc-helper
about
A tool/utility that simply helps manage the init and services.
usage
It has a simple usage with a simple form:
rc-helper <command> <args>
these are the commands it accepts as of now:
- install | installs a file to /etc/rc.services
- start | starts a service
- stop | stops a service
- version | shows the version of helper
- help | shows the usage + version
rc-exec
about
Its a tool to automaticly restart a command/process when it dies or crashes unexpectedly
usage
its also super simple:
rc-exec <command>
you can override the limit on restarts set in config.go by setting the RC_EXEC_LIMIT enviorment variable (-1 makes it always restart on crash/death).
RC_EXEC_LIMIT=<number> rc-exec <command>
so for example
you could do
rc-exec printf "hello %s" "world"
would run it, if it fails then it restarts, else if it exits cleanly or gets SIGTERM or SIGINT it doesnt restart
default services
they are just a bunch of default services you could use. They depend on rc-exec
i highly reccomend editing rc.list before install or editing /etc/rc.list after install to suit your system
TODO/Plans
- futher improve init, rc-exec
- rewrite rc-helper to have more modern features
- make scripts better and use rc-exec in them