[fix] Changelog location should be configurable and piped content work with self call of sudo

This commit is contained in:
alban 2020-06-03 21:50:40 +02:00
parent 0adaf05483
commit a5cf3456c6
2 changed files with 12 additions and 4 deletions

View File

@ -1,17 +1,24 @@
#!/bin/bash #!/bin/bash
#Manages an /etc/changelog #Manages an /etc/changelog
# Immediately attempt to read from named pipe
# And store the piped content if provided
[[ -p /proc/self/fd/0 ]] && export STDIN=$( cat )
# And then force the input to be from terminal
exec 0</dev/tty
# Defining some path variables
APP_PATH=$( cd $(dirname ${BASH_SOURCE[0]}) && pwd ) APP_PATH=$( cd $(dirname ${BASH_SOURCE[0]}) && pwd )
APP_NAME=$( basename ${BASH_SOURCE[0]}) APP_NAME=$( basename ${BASH_SOURCE[0]})
STDIN=$( cat )
ls -lh /proc/self/fd
exec 0</dev/tty
CHANGELOG=/etc/changelog
# %CONFIG% This comment is used to build custom scripts # %CONFIG% This comment is used to build custom scripts
[[ -f "$APP_PATH/config.sh" ]] && source "$APP_PATH/config.sh" [[ -f "$APP_PATH/config.sh" ]] && source "$APP_PATH/config.sh"
# Sanity check on changelog file # Sanity check on changelog file
[[ -n "$CHANGELOG" ]] && CHANGELOG="/etc/Changelog"
[[ -f "$CHANGELOG" ]] && [[ ! -w "$CHANGELOG" ]] && RUN_SUDO=1 [[ -f "$CHANGELOG" ]] && [[ ! -w "$CHANGELOG" ]] && RUN_SUDO=1
[[ ! -f "$CHANGELOG" ]] && ! touch /etc/changelog &>/dev/null && RUN_SUDO=1 [[ ! -f "$CHANGELOG" ]] && ! touch /etc/changelog &>/dev/null && RUN_SUDO=1
[[ $RUN_SUDO -eq 1 ]] && { [[ $RUN_SUDO -eq 1 ]] && {

View File

@ -1,3 +1,4 @@
CHANGELOG=/etc/Changelog
CHANGELOG_SERVER=https://changelog.example.com CHANGELOG_SERVER=https://changelog.example.com
CHANGELOG_AUTH_KEY=your-shared-secret CHANGELOG_AUTH_KEY=your-shared-secret
HASTEBIN_SERVER=https://hastebin.com HASTEBIN_SERVER=https://hastebin.com