Compare commits
No commits in common. "895cab87b4bd8509214c4c0bd5aaddab35325fec" and "dddd30aa96479e6c87d72c3ee18a277a65bcad1a" have entirely different histories.
895cab87b4
...
dddd30aa96
48
README.md
48
README.md
@ -5,61 +5,31 @@ Based on the Masters Book of Serious Sysadmin's Best Practices Chapter, this scr
|
||||
## Crash course
|
||||
|
||||
```
|
||||
wget https://git.interhacker.space/alban/changelog/raw/branch/master/changelog.sh
|
||||
wget https://this.repo.srs.ly/alban/changelog/bla/bla/raw/changelog
|
||||
chmod +x changelog
|
||||
sudo -E ./changelog
|
||||
sudo ./changelog
|
||||
```
|
||||
|
||||
## How it works
|
||||
|
||||
The script will ask for your name if no `CHANGELOG_USERNAME` environment variable is found.
|
||||
|
||||
Then it will ask for change informations:
|
||||
Then it will ask for a first change informations:
|
||||
|
||||
* The nature of the change: which software / domain did you change? Why?
|
||||
* Some comments: How did you do it? What was happening? Is it fixed?
|
||||
|
||||
You can then add multiple lines for a single change as well as multiple changes for a changelog entry (ex: deploy a new service and remove old packages).
|
||||
|
||||
This changelog entry is now inserted on top of the /etc/changelog file, which is created with a default entry if not present yet.
|
||||
|
||||
**Limitations**
|
||||
|
||||
* Please note that to enter multiline comments, you have for now to escape newline characters using the `\\\\n` sequence. Ugly.
|
||||
* Please note that to enter multiline comments, you have for now to escape newline characters using the `\\\\n` sequence. Ugly.
|
||||
|
||||
* By default, it will attempt to create and edit `/etc/changelog`. You better be running it as root, by default.
|
||||
|
||||
## Plugins and config
|
||||
|
||||
You can add plugins to hook actions at two points in time. The `plugins-available` directory contains two working examples of these hooks.
|
||||
# Possible improvements
|
||||
|
||||
* adding a changelog entry lines. Example `content-hastebin.sh` plugin pushes a file content to a pastebin service
|
||||
* saving the changelog. Example `output-changelog-server.sh` plugin pushes a changelog to a remote central server
|
||||
|
||||
You can activate the plugins by placing/linking them in the `plugins-enabled` directory.
|
||||
|
||||
The plugins might need some configuration variables.
|
||||
|
||||
Do `mv config.sample.sh config.sh` and edit the file to suit your needs.
|
||||
|
||||
|
||||
|
||||
## Baking a fat exec
|
||||
|
||||
While providing a mean to run plugins is cool, it's not very efficient at deployment time.
|
||||
|
||||
Run `build.sh` to get a single exec, ready for shipping, embedding:
|
||||
|
||||
* your config.sh file
|
||||
* all the plugins you added to plugins-enabled
|
||||
|
||||
## Possible improvements
|
||||
|
||||
* [x] Enable a sudo requirement / ways to restart oneself as a root user
|
||||
* [] Enable simple multiline comments
|
||||
* [x] Provide a way to attach files
|
||||
* [x] Provide a way (plugins?) to report each change to a central server
|
||||
* [x] Provide a build system to cook config and plugins in a single exec
|
||||
* Enable a sudo requirement / ways to restart oneself as a root user
|
||||
* Enable simple multiline comments
|
||||
* Provide a way to attach files
|
||||
* Provide a way (plugins?) to report each change to a central server
|
||||
|
||||
|
||||
|
||||
|
14
changelog.sh
14
changelog.sh
@ -1,23 +1,21 @@
|
||||
#!/bin/bash
|
||||
#Manages an /etc/changelog
|
||||
|
||||
# %CONFIG% This comment is used to build custom scripts
|
||||
|
||||
echo ${BASH_SOURCE[@]}
|
||||
APP_PATH=$( cd $(dirname ${BASH_SOURCE[0]}) && pwd )
|
||||
APP_NAME=$( basename ${BASH_SOURCE[0]})
|
||||
CHANGELOG=/etc/changelog
|
||||
|
||||
[[ -w /etc/changelog ]] || {
|
||||
echo -e "\nYou cannot write to $CHANGELOG... This doesn't look serious!\n"
|
||||
read -e -i y -n 1 -p "Run as sudo [Yn]? : "
|
||||
[[ "Y" == ${REPLY^} ]] && sudo -E "$APP_PATH/$APP_NAME" && exit 0
|
||||
[[ "Y" == ${REPLY^} ]] && sudo -E $0
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
CHANGELOG=/etc/changelog
|
||||
# %CONFIG% This comment is used to build custom scripts
|
||||
[[ -f "$APP_PATH/config.sh" ]] && source "$APP_PATH/config.sh"
|
||||
|
||||
# functions
|
||||
|
||||
msg(){ echo -e "$@"; }
|
||||
panic(){ msg "${@} Exiting."; exit 1;}
|
||||
ENTRY_FILE=$(mktemp)
|
||||
@ -87,7 +85,7 @@ PLUGIN_OUTPUT+=("hookOutputFile")
|
||||
declare -a PLUGIN_OUTPUT_MENU
|
||||
|
||||
# %PLUGIN% This comment is used to build custom scripts
|
||||
[[ -d "$APP_PATH/plugins-enabled" ]] && [[ -n "$APP_PATH/plugins-enabled/*" ]] && source "$APP_PATH"/plugins-enabled/*
|
||||
[[ -d "plugins-enabled" ]] && [[ -n "plugins-enabled/*" ]] && source plugins-enabled/*
|
||||
|
||||
for (( i = 0; i < ${#PLUGIN_OUTPUT[@]} ; i++ )); do
|
||||
TXT=$( ${PLUGIN_OUTPUT[$i]} )
|
||||
|
@ -1,3 +0,0 @@
|
||||
CHANGELOG_SERVER=https://changelog.example.com
|
||||
CHANGELOG_AUTH_KEY=your-shared-secret
|
||||
HASTEBIN_SERVER=https://hastebin.com
|
Loading…
Reference in New Issue
Block a user