{"id":13783027,"url":"https://github.com/Daniel-Abrecht/unitscript","last_synced_at":"2025-05-11T17:30:43.121Z","repository":{"id":89384544,"uuid":"105925298","full_name":"Daniel-Abrecht/unitscript","owner":"Daniel-Abrecht","description":"Interpreter for descriptive unit file like init scripts in yaml for sysv-rc","archived":false,"fork":false,"pushed_at":"2019-02-11T23:58:13.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-09T13:33:22.327Z","etag":null,"topics":["initscript","interpreter","sysvinit","yaml"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Daniel-Abrecht.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-10-05T18:26:12.000Z","updated_at":"2019-02-11T23:58:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"f913ea9a-8145-4561-b1f3-5aadf5a7fcc7","html_url":"https://github.com/Daniel-Abrecht/unitscript","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daniel-Abrecht%2Funitscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daniel-Abrecht%2Funitscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daniel-Abrecht%2Funitscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daniel-Abrecht%2Funitscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Daniel-Abrecht","download_url":"https://codeload.github.com/Daniel-Abrecht/unitscript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213838135,"owners_count":15645781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["initscript","interpreter","sysvinit","yaml"],"created_at":"2024-08-03T18:01:51.362Z","updated_at":"2024-08-03T18:11:10.746Z","avatar_url":"https://github.com/Daniel-Abrecht.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# unitscript\n\nThis program can be used as an interpreter for unitscripts, which are yaml based init scripts.\nUnitscripts could be used as easier alternative to shell scripts as init scripts or to standardise init scripts\nacross many different sysv-rc compatible distributions. This project was created to show how to create something\nsimilar to systemd units which could be used to standardise init scripts across distributions but using\nexisting technologies and without imposing a system which has since grown way bayond any reasonable scope on everybody.\n\nThis project does only provide some basic functionality to start and stop programs at the moment and may be extendet\nby additional features in the future. It will, however, never become a daemon in the classical sense and unitscripts\nwill never do anything else than managing services.\n\n## Currently supported actions\n\n| action | description |\n|-----------|-------------|\n| start | Starts the program. The script won't exit until the 'start check' condition is met. |\n| stop | Stops the program by sending it a SIGTERM signal. Won't exit until the process whose pid is written in the pid file doesn't exist anymore or an error occurs. |\n| restart | shorthand for start and stop actions. |\n| status | Returns if the process is running and on which pid or not. Exit code will be either 0 for yes, 1 fo no, or anything else to indicate an error. |\n| check | Does nothing, but will still exit with an error message if the unitscript contains an error |\n| zap | Removes the pid file |\n\n## Format\n\nA unitscript consists of the shebang line ```#!/usr/bin/env unitscript```, followed by an LSB Header,\nfollowed by the unitscript options. The wholeunit script is a valid yaml file.\n\nThe following unitscript options are currently supported:\n\n| option      | type    | description |\n|-------------|---------|-------------|\n| user        | string  | A valid user name from /etc/passwd |\n| group       | string  | A valid group name from /etc/group |\n| start check | string  | Can be either exit, start, or notification. \u003cbr/\u003e exit: The process forks itself, wait until it exits and check the return code. \u003cbr/\u003e start: The moment the executable is executed is considered a successful start. \u003cbr/\u003e notification: The process writes a newline to a file descriptor to indicate the start succeeded. You can specify the file descriptor using the notifyfd property, default is 3. |\n| program     | string  | A shell script. The default interpreter is ```sh -l```, but can be overwritten using a shebang line |\n| uid         | integer | A user id of a valid user from /etc/passwd |\n| gid         | integer | A group id of a valid group from /etc/group |\n| notifyfd    | integer | Used if ```start check``` is set to notification. Default is 3. |\n| logging     | string  | If and how stdout and stdin should be redirected. Can be either: default, syslog, stdio or none. \u003cbr/\u003e default: equivalent to syslog if 'start check' is 'start', stdout if 'start check' is 'exit', invalid otherwise. \u003cbr/\u003e syslog: redirect stdout and stderr to syslog before executing 'program'. \u003cbr/\u003e stdio: keep stdout and stderr unchanged \u003cbr/\u003e none: close stdout and stderr before execution. |\n| pidfile     | string  | Defaults to /var/run/unitscript/\u003cscript name\u003e.pid |\n| manage pidfile | boolean | Either yes or no. Specifies if the program or the unit script should create the pid file. \u003cbr/\u003e Default for 'start check' 'exit' is 'no'. \u003cbr/\u003e Default for 'start check' 'start' is 'yes'. |\n| env         | map     | Environment variables to set before program execution |\n| env scripts | list    | A list of posix shell scripts. The variables those scripts define will be exported as environment variables before executing the program |\n| env files   | list    | A list of files similar in syntax to /etc/environment. The variables those scripts define will be exported as environment variables before executing the program |\n| working directory | string | Sets the working directory. Defaults to the user home directory. |\n| umask       | integer | The umask using which the program is started, defaults to 0022 |\n| rlimits     | map     | All posix rlimits and some system specific ones can be set. The name of the rlimit should be in lower case and shouldn't be prefixed with RLIMIT_. The value for an rlimit can either be an integer, which will set the cur and max rlimit values, or ```max:cur```, where max and cur are integers used to set the max and cur values of the rlimit. |\n\n## Environment variables\n\nAll environment variables will be cleared before execution, but per default a sh login shell is used to start the program,\nwhich should source /etc/profile and .profile, which may set some basic environment variables like the PATH variable.\nIn addition to this, all variables specified using the 'env', 'env files' and 'env scripts' option and the following ones will be set:\n\n| variable | description |\n|----------|-------------|\n| SHELL    | The shell specified for the user in /etc/passwd |\n| HOME     | The user home directory as specified in /etc/passwd |\n| PIDFILE  | The location of the pid file |\n| NOTIFICATION_FD | The file descriptor number using which the program can indicate that it finished starting up |\n\n\n## Build requirements\n\nThis project requires my dpaparser project for building. You can find it at\nhttps://github.com/Daniel-Abrecht/dpaparser\nhttps://gitlab.com/DanielAbrecht/dpaparser\nOr wherever else I'll put a copy of my projects in addition to that in the future.\n\nYou'll also need libbsd and libyaml.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaniel-Abrecht%2Funitscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDaniel-Abrecht%2Funitscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaniel-Abrecht%2Funitscript/lists"}