Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/can-sahin/sample-service-script
Sample SystemV init script (service script) for rpm-based linux, that is compatible with Amazon Linux AMI
https://github.com/can-sahin/sample-service-script
amazonlinux initscript
Last synced: 11 days ago
JSON representation
Sample SystemV init script (service script) for rpm-based linux, that is compatible with Amazon Linux AMI
- Host: GitHub
- URL: https://github.com/can-sahin/sample-service-script
- Owner: Can-Sahin
- Created: 2018-01-12T09:58:52.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-14T16:05:06.000Z (almost 7 years ago)
- Last Synced: 2024-10-06T07:21:39.262Z (about 1 month ago)
- Topics: amazonlinux, initscript
- Language: Shell
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Sample Service Script for Amazon (RHEL-based) Linux AMI
Sample System V init script (service script) for startup services that is written for [Amazon Linux AMI] (and therefore for RHEL-based linux). Alternative to 'linux daemons' which AWS Linux AMI does not support.Original script is taken from [wyhasany's script]
And:
- Modified and improved for running on Amazon's RHEL-compatible Linux Image
- Added Environment Variables configuration at startup to enable different configurations at the runtime (for stages like 'Dev', 'Prod'...)Look at [LSB init scripts] / System V init scripts for more information.
## Usage
Download the script ExampleService.sh
Some example values and implementation is provided in the script. For now, on run it writes Environment Values to the log file
Edit the script by replacing the fields in between the `` tag with your own values:
* Modify the LSB header. Change `ExampleService` with your name and change default configuration if you wish
* `SERVICE_NAME` = Your service's name
* `SCRIPT` = Your script to run on service start
* `RUNAS` = User to run the `SCRIPT` as
* `PidFileLocation` = Location of PIDFILE to store
* `LogFileLocation` = Location of LOGFILE to store
* Optionally customize Environment Values according to the Runtime as its explained in the scriptStart and test your service:
**Install the service to `/etc/init.d` with install command**
```sh
# sh {YOUR_SCRIPT_NAME} install
sh ExampleService.sh install
```
It configures the service to `chkconfig`. If you don't want to run at boot-time then delete it from `chkconfig`
```sh
# chkconfig --del {YOUR_SERVICE_NAME}
chkconfig --del ExampleService
```**Start the service**
```sh
service ExampleService start
```**Start the service with custom Environment Variables.**
If you define Environment Variables for ,say, 'Dev' in the script like;
`EnvironmentVariables_Dev=( "ConnString:DevString" "ASPNETCORE_ENVIRONMENT:Dev" )
`then start the service with `--environment` option
```sh
service ExampleService --environment Dev start
```
**Other commands**` start , stop , status , restart , install , uninstall`
Usage:
`service ExampleService --environment Dev {optional} start | stop | status | restart | install | uninstall`[Amazon Linux AMI]: https://aws.amazon.com/amazon-linux-ami/
[wyhasany's script]: https://github.com/wyhasany/sample-service-script
[LSB init scripts]: https://wiki.debian.org/LSBInitScripts