New step for distribution detection
Adapt echo to echoseq
This commit is contained in:
75
seqs/snmp.sh
75
seqs/snmp.sh
@@ -28,17 +28,17 @@ step_2() {
|
||||
## Create authentication entry
|
||||
exep "cat \"$v3AuthLoc\" | grep -e '^\s*usmUser'"
|
||||
if [ "$?" == "0" ]; then
|
||||
echo
|
||||
echoseq
|
||||
|
||||
exe read -p "User entry found. Continue: y/n(default)? " answer
|
||||
case $answer in
|
||||
[yY])
|
||||
echo
|
||||
echo Continuing installation...
|
||||
echoseq
|
||||
echoseq "Continuing installation..."
|
||||
;;
|
||||
*)
|
||||
echo
|
||||
echo Installation aborted
|
||||
echoseq
|
||||
echoseq "Installation aborted"
|
||||
return 1;
|
||||
;;
|
||||
esac
|
||||
@@ -46,14 +46,14 @@ step_2() {
|
||||
|
||||
read -p "SNMPv3 Username: " v3User
|
||||
read -p "SNMPv3 Password: " v3Pass
|
||||
echo
|
||||
echoseq
|
||||
read -p "Repeat Password: " v3Pass2
|
||||
|
||||
if [ "$v3Pass" != "$v3Pass2" ] ; then
|
||||
echoerr " [E] Password mismatch"
|
||||
return 1
|
||||
fi
|
||||
echo
|
||||
echoseq
|
||||
|
||||
exe service snmpd stop
|
||||
|
||||
@@ -64,7 +64,7 @@ step_2() {
|
||||
|
||||
shift
|
||||
if [ ! -z $1 ] && [ "$1" == "-s" ] ; then
|
||||
echo " [I] Stop after creating authentication config"
|
||||
echoseq " [I] Stop after creating authentication config"
|
||||
exe service snmpd start
|
||||
return 0
|
||||
fi
|
||||
@@ -152,9 +152,9 @@ step_25() {
|
||||
fi
|
||||
case $answer in
|
||||
[yY])
|
||||
echo " [I] Opening interactive shell. Type \"exit\" to return to this script."
|
||||
echoseq " [I] Opening interactive shell. Type \"exit\" to return to this script."
|
||||
exe bash -i
|
||||
echo " [I] Interactive shell ended. Continuing with $0."
|
||||
echoseq " [I] Interactive shell ended. Continuing with $0."
|
||||
exe nginx -t
|
||||
endReturn -o $? "Nginx configuration error"
|
||||
|
||||
@@ -211,9 +211,9 @@ phpfpmExtendLoc="${toolConfigLoc}/phpfpmsp"
|
||||
step_29_info() { echo "Prepare nginx to provide status to $toolName"; }
|
||||
step_29_alias() { ALIAS="nginx"; }
|
||||
step_29() {
|
||||
echo -e "\n [!] Please add the following to your default server:\n"
|
||||
echo "$nginxStatus"
|
||||
echo
|
||||
echoseq -e "\n [!] Please add the following to your default server:\n"
|
||||
echoseq "$nginxStatus"
|
||||
echoseq
|
||||
if [ $QUIET -ne 0 ] ; then
|
||||
answer=n
|
||||
else
|
||||
@@ -221,9 +221,9 @@ step_29() {
|
||||
fi
|
||||
case $answer in
|
||||
[yY])
|
||||
echo " [I] Opening interactive shell. Type \"exit\" to return to this script."
|
||||
echoseq " [I] Opening interactive shell. Type \"exit\" to return to this script."
|
||||
exe bash -i
|
||||
echo " [I] Interactive shell ended. Continuing with $0."
|
||||
echoseq " [I] Interactive shell ended. Continuing with $0."
|
||||
exe nginx -t
|
||||
endReturn -o $? "Nginx configuration error"
|
||||
|
||||
@@ -287,11 +287,11 @@ step_33() {
|
||||
exe chown root:$toolSysUser "$postfixCacheLoc"
|
||||
exe chmod 770 "$postfixCacheLoc"
|
||||
|
||||
echo " [I] Create symlink /var/log/maillog which is used by postfixdetailed"
|
||||
echoseq " [I] Create symlink /var/log/maillog which is used by postfixdetailed"
|
||||
exe ln -fs /var/log/mail.log /var/log/maillog
|
||||
|
||||
echo " [I] Run /etc/snmp/postfixdetailed to create the initial cache file"
|
||||
echo " so you don't end up with some crazy initial starting value."
|
||||
echoseq " [I] Run /etc/snmp/postfixdetailed to create the initial cache file"
|
||||
echoseq " so you don't end up with some crazy initial starting value."
|
||||
exe sudo -u $toolSysUser "$postfixScript"
|
||||
}
|
||||
postfixCacheLoc="/var/cache/postfixdetailed"
|
||||
@@ -301,9 +301,9 @@ postfixQueuesExtendLoc="${toolConfigLoc}/postfix-queues"
|
||||
step_34_info() { echo "Create sudoers file for postfix scripts"; }
|
||||
step_34() {
|
||||
addConf -s "$postfixSudoersContent" "$postfixSudoersLoc"
|
||||
echo " [I] Changing ${postfixQueuesExtendLoc} to add sudo for qshape"
|
||||
echoseq " [I] Changing ${postfixQueuesExtendLoc} to add sudo for qshape"
|
||||
exe sed -i -E "s/\`qshape/\`sudo qshape/" "${postfixQueuesExtendLoc}"
|
||||
echo " [W] Reboot may be required to make these changes active"
|
||||
echoseq " [W] Reboot may be required to make these changes active"
|
||||
}
|
||||
postfixSudoersLoc="/etc/sudoers.d/snmppostfix"
|
||||
postfixSudoersContent="${toolSysUser} ALL=(ALL) NOPASSWD: /usr/sbin/qshape"
|
||||
@@ -312,12 +312,12 @@ step_35_info() { echo "Create postfix extends (postfixdetailed and postfix-queue
|
||||
step_35() {
|
||||
checkExtend postfix-queues
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " [I] Create postfix-queues extend"
|
||||
echoseq " [I] Create postfix-queues extend"
|
||||
addConf -a "extend mailq ${postfixQueuesExtendLoc}" "$toolConfig"
|
||||
fi
|
||||
checkExtend postfixdetailed
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " [I] Create postfixdetailed extend"
|
||||
echoseq " [I] Create postfixdetailed extend"
|
||||
addConf -a "extend postfixdetailed ${postfixScript}" "$toolConfig"
|
||||
fi
|
||||
|
||||
@@ -340,10 +340,8 @@ step_37(){
|
||||
|
||||
checkExtend fail2ban
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " [I] Create fail2ban extend"
|
||||
echoseq " [I] Create fail2ban extend"
|
||||
addConf -a "extend fail2ban ${fail2banExtendLoc} -c" "$toolConfig"
|
||||
else
|
||||
echo " [W] Fail2ban extend already included"
|
||||
fi
|
||||
|
||||
exe apt install $fail2banDeps $aptOpt
|
||||
@@ -359,21 +357,38 @@ fail2banCronLoc="/etc/cron.d/fail2banCache"
|
||||
fail2banCron="# Update cache for faster fail2ban polling
|
||||
*/3 * * * * root ${fail2banExtendLoc} -u"
|
||||
|
||||
step_40_info() { echo "Create linux distribution detection extend (distro)"; }
|
||||
step_40_alias() { ALIAS="distro"; }
|
||||
step_40() {
|
||||
checkExtend distro
|
||||
if [ $? -ne 0 ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
exe wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro -O "${distroExtendLoc}"
|
||||
endReturn -o $? "Download distro detection script failed"
|
||||
exe chmod +x "$distroExtendLoc"
|
||||
|
||||
echoseq " [I] Create distro extend"
|
||||
addConf -a "extend distro ${distroExtendLoc}" "$toolConfig"
|
||||
|
||||
exe service snmpd restart
|
||||
}
|
||||
distroExtendLoc="${toolConfigLoc}/distro"
|
||||
checkExtend() {
|
||||
# adding dry run output for clarification
|
||||
if [ "$DRY" != "0" ] ; then
|
||||
echo " [I] check if \"extend ${1}\" exists..dry-run"
|
||||
if [ $DRY -ne 0 ] ; then
|
||||
echoseq " [I] check if \"extend ${1}\" exists..dry-run"
|
||||
fi
|
||||
|
||||
exep "cat \"$toolConfig\" | grep -e '^\s*extend\s\+${1}' >>/dev/null 2>&1"
|
||||
# Only warn if entry exists and dry-run is not seleted
|
||||
if [ "$?" == "0" ] && [ "$DRY" == "0" ] ; then
|
||||
echoerr " [W] Extend for ${1} exists"
|
||||
if [ $? -eq 0 ] && [ $DRY -eq 0 ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
VERSION_SEQREV=11
|
||||
VERSION_SEQREV=12
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
Reference in New Issue
Block a user