[fix] Bit of renaming things
This commit is contained in:
parent
e77830a144
commit
d296e615e9
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
|||||||
.*.sw*
|
.*.sw*
|
||||||
|
config.sh
|
||||||
|
build/
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#Manages an /etc/changelog
|
#Manages an /etc/changelog
|
||||||
|
|
||||||
|
# %CONFIG% This comment is used to build custom scripts
|
||||||
|
|
||||||
CHANGELOG=/etc/changelog
|
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 $0
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# functions
|
# functions
|
||||||
|
|
||||||
@ -19,17 +29,17 @@ change(){
|
|||||||
|
|
||||||
for (( ; ; )); do
|
for (( ; ; )); do
|
||||||
echo "Select number or x to quit"
|
echo "Select number or x to quit"
|
||||||
for (( i=0; i<${#HOOKS_CONTENT_MENU[@]}; i++)) ; do
|
for (( i=0; i<${#PLUGIN_CONTENT_MENU[@]}; i++)) ; do
|
||||||
echo "$i) ${HOOKS_CONTENT_MENU[$i]}"
|
echo "$i) ${PLUGIN_CONTENT_MENU[$i]}"
|
||||||
done
|
done
|
||||||
echo "x) No more details."
|
echo "x) No more details."
|
||||||
read -e -n 1 -p "Your choice? :" REPLY
|
read -e -n 1 -p "Your choice? :" REPLY
|
||||||
if [[ "x" == ${REPLY,,} ]]; then
|
if [[ "x" == ${REPLY,,} ]]; then
|
||||||
break
|
break
|
||||||
elif [[ -z "${HOOKS_CONTENT[$REPLY]}" ]] ; then
|
elif [[ -z "${PLUGIN_CONTENT[$REPLY]}" ]] ; then
|
||||||
echo "Unknown Key."
|
echo "Unknown Key."
|
||||||
else
|
else
|
||||||
${HOOKS_CONTENT[$REPLY]} $TMP
|
${PLUGIN_CONTENT[$REPLY]} $TMP
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
read -e -i "n" -p "Another section? [yN]:" END
|
read -e -i "n" -p "Another section? [yN]:" END
|
||||||
@ -37,8 +47,7 @@ change(){
|
|||||||
done
|
done
|
||||||
echo -e "\nHere is the content you are about to add.\n\n$(cat $TMP)\n"
|
echo -e "\nHere is the content you are about to add.\n\n$(cat $TMP)\n"
|
||||||
read -e -p "OK? [Yn]: " -i y RETURN
|
read -e -p "OK? [Yn]: " -i y RETURN
|
||||||
[[ "N" == ${RETURN^^} ]] && return
|
[[ "N" == ${RETURN^^} ]] && return 1
|
||||||
echo $TMP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hookContentComment(){
|
hookContentComment(){
|
||||||
@ -54,6 +63,7 @@ hookOutputFile(){
|
|||||||
TMP="$1"
|
TMP="$1"
|
||||||
cat << HEREDOC >$t
|
cat << HEREDOC >$t
|
||||||
|
|
||||||
|
|
||||||
$(date "+%Y-%m-%d %H:%M") $CHANGELOG_USERNAME
|
$(date "+%Y-%m-%d %H:%M") $CHANGELOG_USERNAME
|
||||||
|
|
||||||
$( echo -e "$@"|sed 's/^/ /' )
|
$( echo -e "$@"|sed 's/^/ /' )
|
||||||
@ -65,29 +75,30 @@ HEREDOC
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Build the hook content menu
|
||||||
|
PLUGIN_CONTENT+=("hookContentComment")
|
||||||
|
declare -a PLUGIN_CONTENT_MENU
|
||||||
|
|
||||||
|
# Build the hook content menu
|
||||||
|
PLUGIN_OUTPUT+=("hookOutputFile")
|
||||||
|
declare -a PLUGIN_OUTPUT_MENU
|
||||||
|
|
||||||
|
# %PLUGIN% This comment is used to build custom scripts
|
||||||
|
[[ -d "plugins-enabled" ]] && [[ -n "plugins-enabled/*" ]] && source plugins-enabled/*
|
||||||
|
|
||||||
|
for (( i = 0; i < ${#PLUGIN_OUTPUT[@]} ; i++ )); do
|
||||||
|
TXT=$( ${PLUGIN_OUTPUT[$i]} )
|
||||||
|
PLUGIN_OUTPUT_MENU+=("$( ${PLUGIN_OUTPUT[$i]} )")
|
||||||
|
done
|
||||||
|
for (( i = 0; i < ${#PLUGIN_CONTENT[@]} ; i++ )); do
|
||||||
|
TXT=$( ${PLUGIN_CONTENT[$i]} )
|
||||||
|
PLUGIN_CONTENT_MENU+=("$( ${PLUGIN_CONTENT[$i]} )")
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
# Exec
|
# Exec
|
||||||
|
|
||||||
# Build the hook content menu
|
|
||||||
HOOKS_CONTENT+=("hookContentComment")
|
|
||||||
declare -a HOOKS_CONTENT_MENU
|
|
||||||
[[ -n "hooks-content/*" ]] && source hooks-content/*
|
|
||||||
for (( i = 0; i < ${#HOOKS_CONTENT[@]} ; i++ )); do
|
|
||||||
TXT=$( ${HOOKS_CONTENT[$i]} )
|
|
||||||
HOOKS_CONTENT_MENU+=("$( ${HOOKS_CONTENT[$i]} )")
|
|
||||||
done
|
|
||||||
|
|
||||||
# Build the hook content menu
|
|
||||||
HOOKS_OUTPUT+=("hookOutputFile")
|
|
||||||
declare -a HOOKS_OUTPUT_MENU
|
|
||||||
[[ -n "hooks-output/*" ]] && source hooks-output/*
|
|
||||||
for (( i = 0; i < ${#HOOKS_OUTPUT[@]} ; i++ )); do
|
|
||||||
TXT=$( ${HOOKS_OUTPUT[$i]} )
|
|
||||||
HOOKS_OUTPUT_MENU+=("$( ${HOOKS_OUTPUT[$i]} )")
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo -e "\nWelcome to Serious Changelogs Inc. Do you have something for me?\n"
|
echo -e "\nWelcome to Serious Changelogs Inc. Do you have something for me?\n"
|
||||||
# set environment variables
|
# set environment variables
|
||||||
[[ -z "$CHANGELOG_USERNAME" ]] && read -e -p "Your name? " NAME&& read -e -p "Your email? " EMAIL && CHANGELOG_USERNAME="${NAME^} <$EMAIL>" && echo "export CHANGELOG_USERNAME=\"$CHANGELOG_USERNAME\""
|
[[ -z "$CHANGELOG_USERNAME" ]] && read -e -p "Your name? " NAME&& read -e -p "Your email? " EMAIL && CHANGELOG_USERNAME="${NAME^} <$EMAIL>" && echo "export CHANGELOG_USERNAME=\"$CHANGELOG_USERNAME\""
|
||||||
@ -99,9 +110,11 @@ echo -e "\nWelcome to Serious Changelogs Inc. Do you have something for me?\n"
|
|||||||
# parse command
|
# parse command
|
||||||
change "$ENTRY_FILE"
|
change "$ENTRY_FILE"
|
||||||
|
|
||||||
for (( i=0; i<${#HOOKS_OUTPUT_MENU[@]}; i++)) ; do
|
[[ $? -eq 0 ]] && exit
|
||||||
echo "${HOOKS_OUTPUT_MENU[$i]}"
|
|
||||||
${HOOKS_OUTPUT[$i]} $ENTRY_FILE
|
for (( i=0; i<${#PLUGIN_OUTPUT_MENU[@]}; i++)) ; do
|
||||||
|
echo "${PLUGIN_OUTPUT_MENU[$i]}"
|
||||||
|
${PLUGIN_OUTPUT[$i]} $ENTRY_FILE
|
||||||
done
|
done
|
||||||
|
|
||||||
rm "$ENTRY_FILE"
|
rm "$ENTRY_FILE"
|
@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
HOOKS_OUTPUT+=( hookOutputChangelogServer )
|
|
||||||
|
|
||||||
CHANGELOG_SERVER=http://localhost:3000
|
|
||||||
|
|
||||||
hookOutputChangelogServer(){
|
|
||||||
|
|
||||||
[[ -z "$1" ]] && echo "Sending changelog to remote server" && return
|
|
||||||
CONTENT=$(jq -aRs . $1|tr '"' '\"')
|
|
||||||
PAYLOAD="{\"author\":\"$CHANGELOG_USERNAME\",\"server\":\"$(hostname -f)\",\"content\":${CONTENT}}"
|
|
||||||
URL=$( curl -X POST -H "Content-Type: application/json" -s -d "${PAYLOAD}" "$CHANGELOG_SERVER/changelog/_doc"; )
|
|
||||||
echo "$FILE: $URL" >> $TMP
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Sends the changelog information to a changelog server
|
||||||
HOOKS_CONTENT+=( hookContentHastebin )
|
# see https://git.interhacker.space/alban/changelog-server
|
||||||
|
# Requires an environmental variable to work
|
||||||
HASTEBIN_SERVER=https://paste.interhacker.space
|
# ex: HASTEBIN_SERVER=https://paste.interhacker.space
|
||||||
|
PLUGIN_CONTENT+=( hookContentHastebin )
|
||||||
hookContentHastebin(){
|
hookContentHastebin(){
|
||||||
|
|
||||||
[[ -z "$1" ]] && echo "Store a file by name in pastebin" && return
|
[[ -z "$1" ]] && echo "Store a file by name in pastebin" && return
|
||||||
|
[[ -z "$HASTEBIN_SERVER" ]] && echo "Missing HASTEBIN_SERVER variable. Exiting." && return
|
||||||
TMP="$1"
|
TMP="$1"
|
||||||
read -e -p "File location? " FILE
|
read -e -p "File location? " FILE
|
||||||
[[ ! -f $FILE ]] && panic "Not a valid file" && exit
|
[[ ! -f $FILE ]] && panic "Not a valid file" && exit
|
||||||
URL=$( curl -X POST -s -d "$(cat "$FILE" )" "$HASTEBIN_SERVER/documents" | awk -F '"' '{print "'$HASTEBIN_SERVER'/raw/"$4}'; )
|
URL=$( curl -X POST -s -d "$(cat "$FILE" )" "$HASTEBIN_SERVER/documents" | awk -F '"' '{print "'$HASTEBIN_SERVER'/raw/"$4}'; )
|
||||||
echo "$FILE: $URL" >> $TMP
|
echo "$FILE: $URL" >> $TMP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
18
plugins-available/output-changelog-server.sh
Normal file
18
plugins-available/output-changelog-server.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Sends the changelog information to a changelog server
|
||||||
|
# see https://git.interhacker.space/alban/changelog-server
|
||||||
|
# Requires environmental variables to work
|
||||||
|
# CHANGELOG_SERVER
|
||||||
|
# CHANGELOG_AUTH_KEY
|
||||||
|
PLUGIN_OUTPUT+=( hookOutputChangelogServer )
|
||||||
|
hookOutputChangelogServer(){
|
||||||
|
[[ -z "$1" ]] && echo "Sending changelog to remote server" && return
|
||||||
|
[[ -z "$CHANGELOG_SERVER" ]] && echo "Missing CHANGELOG_SERVER variable. Exiting." && return
|
||||||
|
[[ -z "$CHANGELOG_AUTH_KEY" ]] && echo "Missing CHANGELOG_AUTH_KEY variable. Exiting." && return
|
||||||
|
CONTENT=$(jq -aRs . $1|tr '"' '\"')
|
||||||
|
PAYLOAD="{\"author\":\"$CHANGELOG_USERNAME\",\"server\":\"$(hostname -f)\",\"content\":${CONTENT}}"
|
||||||
|
URL=$( curl -X POST -H "AuthorizationToken: $CHANGELOG_AUTH_KEY" -H "Content-Type: application/json" -s -d "${PAYLOAD}" "$CHANGELOG_SERVER/changelog/_doc"; )
|
||||||
|
[[ 0 -ne $? ]] && echo "Failed to upload the changelog..." && return
|
||||||
|
echo "$FILE: $URL" >> $TMP
|
||||||
|
}
|
||||||
|
|
1
plugins-enabled/.gitignore
vendored
Normal file
1
plugins-enabled/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*
|
Loading…
Reference in New Issue
Block a user