Merge branch 'master' of https://git.johnhgaunt.com/jgaunt/homelab-scripts
This commit is contained in:
53
backupBSD.sh
53
backupBSD.sh
@@ -17,37 +17,54 @@ fi
|
|||||||
# Backup GauntRouter01
|
# Backup GauntRouter01
|
||||||
DNSName="gauntrouter01.home.johnhgaunt.com"
|
DNSName="gauntrouter01.home.johnhgaunt.com"
|
||||||
GauntRouterSSHFSMountDirectory="${SSHFSMountDirectory}/${DNSName}"
|
GauntRouterSSHFSMountDirectory="${SSHFSMountDirectory}/${DNSName}"
|
||||||
/usr/bin/mkdir ${GauntRouterSSHFSMountDirectory} && \
|
/usr/bin/mkdir -v ${GauntRouterSSHFSMountDirectory} && \
|
||||||
/usr/bin/echo ${GauntRouter01EncryptedRootPassword} | \
|
/usr/bin/echo ${GauntRouter01EncryptedRootPassword} | \
|
||||||
/usr/bin/clevis decrypt | \
|
/usr/bin/clevis decrypt | \
|
||||||
/usr/bin/sshfs -o password_stdin root@${DNSName}:/ ${GauntRouterSSHFSMountDirectory} && \
|
/usr/bin/sshfs -o password_stdin -o ro \
|
||||||
/usr/bin/proxmox-backup-client backup conf.pxar:${GauntRouterSSHFSMountDirectory}/conf bpsensei.pxar:${GauntRouterSSHFSMountDirectory}/usr/local/bpsensei --backup-id GauntRouter01 --ns Hosts --repository GauntPBS01-Helper@pbs@gauntpbs01.home.johnhgaunt.com:8007:GauntPBS01-Local
|
root@${DNSName}:/ ${GauntRouterSSHFSMountDirectory} && \
|
||||||
|
/usr/bin/proxmox-backup-client backup \
|
||||||
|
conf.pxar:${GauntRouterSSHFSMountDirectory}/conf \
|
||||||
|
bpsensei.pxar:${GauntRouterSSHFSMountDirectory}/usr/local/bpsensei \
|
||||||
|
--backup-id GauntRouter01 \
|
||||||
|
--ns Hosts \
|
||||||
|
--repository GauntPBS01-Helper@pbs@gauntpbs01.home.johnhgaunt.com:8007:GauntPBS01-Local
|
||||||
# umount and remove directory
|
# umount and remove directory
|
||||||
/usr/bin/umount --force --lazy --quiet ${GauntRouterSSHFSMountDirectory} && \
|
/usr/bin/umount -v --force --lazy --quiet ${GauntRouterSSHFSMountDirectory} && \
|
||||||
/usr/bin/rmdir ${GauntRouterSSHFSMountDirectory}
|
/usr/bin/rmdir -v ${GauntRouterSSHFSMountDirectory}
|
||||||
|
|
||||||
# Backup TheGauntsRouter
|
# Backup TheGauntsRouter
|
||||||
DNSName="172.21.0.6"
|
DNSName="10.1.4.2"
|
||||||
TheGauntsRouterSSHFSMountDirectory="${SSHFSMountDirectory}/${DNSName}"
|
TheGauntsRouterSSHFSMountDirectory="${SSHFSMountDirectory}/${DNSName}"
|
||||||
/usr/bin/mkdir ${TheGauntsRouterSSHFSMountDirectory} && \
|
/usr/bin/mkdir -v ${TheGauntsRouterSSHFSMountDirectory} && \
|
||||||
/usr/bin/echo ${TheGauntsRouterEncryptedRootPassword} | \
|
/usr/bin/echo ${TheGauntsRouterEncryptedRootPassword} | \
|
||||||
/usr/bin/clevis decrypt | \
|
/usr/bin/clevis decrypt | \
|
||||||
/usr/bin/sshfs -o password_stdin root@${DNSName}:/ ${TheGauntsRouterSSHFSMountDirectory} && \
|
/usr/bin/sshfs -o password_stdin -o ro \
|
||||||
/usr/bin/proxmox-backup-client backup conf.pxar:${TheGauntsRouterSSHFSMountDirectory}/conf bpsensei.pxar:${TheGauntsRouterSSHFSMountDirectory}/usr/local/bpsensei --backup-id
|
root@${DNSName}:/ ${TheGauntsRouterSSHFSMountDirectory} && \
|
||||||
TheGauntsRouter --ns Hosts --repository GauntPBS01-Helper@pbs@gauntpbs01.home.johnhgaunt.com:8007:GauntPBS01-Local
|
/usr/bin/proxmox-backup-client backup \
|
||||||
|
conf.pxar:${TheGauntsRouterSSHFSMountDirectory}/conf \
|
||||||
|
bpsensei.pxar:${TheGauntsRouterSSHFSMountDirectory}/usr/local/bpsensei \
|
||||||
|
--backup-id TheGauntsRouter \
|
||||||
|
--ns Hosts \
|
||||||
|
--repository GauntPBS01-Helper@pbs@gauntpbs01.home.johnhgaunt.com:8007:GauntPBS01-Local
|
||||||
# umount and remove directory
|
# umount and remove directory
|
||||||
/usr/bin/umount --force --lazy --quiet ${TheGauntsRouterSSHFSMountDirectory} && \
|
/usr/bin/umount -v --force --lazy --quiet ${TheGauntsRouterSSHFSMountDirectory} && \
|
||||||
/usr/bin/rmdir ${TheGauntsRouterSSHFSMountDirectory}
|
/usr/bin/rmdir -v ${TheGauntsRouterSSHFSMountDirectory}
|
||||||
|
|
||||||
# Backup GauntNAS
|
# Backup GauntNAS
|
||||||
DNSName="gauntnas.home.johnhgaunt.com"
|
DNSName="gauntnas.home.johnhgaunt.com"
|
||||||
GauntNASSSHFSMountDirectory="${SSHFSMountDirectory}/${DNSName}"
|
GauntNASSSHFSMountDirectory="${SSHFSMountDirectory}/${DNSName}"
|
||||||
/usr/bin/mkdir ${GauntNASSSHFSMountDirectory} && \
|
/usr/bin/mkdir -v ${GauntNASSSHFSMountDirectory} && \
|
||||||
/usr/bin/echo ${GauntNASEncryptedRootPassword} | \
|
/usr/bin/echo ${GauntNASEncryptedRootPassword} | \
|
||||||
/usr/bin/clevis decrypt | \
|
/usr/bin/clevis decrypt | \
|
||||||
/usr/bin/sshfs -o password_stdin root@${DNSName}:/ ${GauntNASSSHFSMountDirectory} && \
|
/usr/bin/sshfs -o password_stdin -o ro \
|
||||||
/usr/bin/proxmox-backup-client backup data.pxar:${GauntNASSSHFSMountDirectory}/data etc.pxar:${GauntNASSSHFSMountDirectory}/etc root.pxar:${GauntNASSSHFSMountDirectory}/root
|
root@${DNSName}:/ ${GauntNASSSHFSMountDirectory} && \
|
||||||
--backup-id GauntNAS --ns Hosts --repository GauntPBS01-Helper@pbs@gauntpbs01.home.johnhgaunt.com:8007:GauntPBS01-Local
|
/usr/bin/proxmox-backup-client backup \
|
||||||
|
data.pxar:${GauntNASSSHFSMountDirectory}/data \
|
||||||
|
etc.pxar:${GauntNASSSHFSMountDirectory}/etc \
|
||||||
|
root.pxar:${GauntNASSSHFSMountDirectory}/root \
|
||||||
|
--backup-id GauntNAS \
|
||||||
|
--ns Hosts \
|
||||||
|
--repository GauntPBS01-Helper@pbs@gauntpbs01.home.johnhgaunt.com:8007:GauntPBS01-Local
|
||||||
# umount and remove directory
|
# umount and remove directory
|
||||||
/usr/bin/umount --force --lazy --quiet ${GauntNASSSHFSMountDirectory} && \
|
/usr/bin/umount -v --force --lazy --quiet ${GauntNASSSHFSMountDirectory} && \
|
||||||
/usr/bin/rmdir ${GauntNASSSHFSMountDirectory}
|
/usr/bin/rmdir -v ${GauntNASSSHFSMountDirectory}
|
||||||
17
checkmk.sh
17
checkmk.sh
@@ -6,6 +6,13 @@ if [ "$EUID" -ne 0 ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ask for the domain, username, and password
|
||||||
|
read -e -p "Enter Checkmk Server: " -i "gauntcheckmk.home.johnhgaunt.com" CHECK_MK_SERVER
|
||||||
|
read -e -p "Enter Checkmk Site Name: " -i "gaunt" SITE_NAME
|
||||||
|
read -e -p "Enter Checkmk Username: " -i "automation" USERNAME
|
||||||
|
read -e -s -p "Enter ${USERNAME}'s Password: " PASSWORD
|
||||||
|
|
||||||
|
|
||||||
# get OS ditro and version
|
# get OS ditro and version
|
||||||
OS=$(hostnamectl | awk '/Operating System/ {print $3}')
|
OS=$(hostnamectl | awk '/Operating System/ {print $3}')
|
||||||
VM=$(hostnamectl | awk '/Virtualization/ {print $2}')
|
VM=$(hostnamectl | awk '/Virtualization/ {print $2}')
|
||||||
@@ -24,12 +31,8 @@ fi
|
|||||||
set -e
|
set -e
|
||||||
# set -x
|
# set -x
|
||||||
|
|
||||||
CHECK_MK_SERVER="gauntcheckmk.home.johnhgaunt.com"
|
|
||||||
SITE_NAME="gaunt"
|
|
||||||
API_URL="http://${CHECK_MK_SERVER}/${SITE_NAME}/check_mk/api/1.0"
|
API_URL="http://${CHECK_MK_SERVER}/${SITE_NAME}/check_mk/api/1.0"
|
||||||
USERNMAE="automation"
|
AUTHORIZATION_HEADER="Authorization: Bearer ${USERNAME} ${PASSWORD}"
|
||||||
PASSWORD="$1"
|
|
||||||
AUTHORIZATION_HEADER="Authorization: Bearer ${USERNMAE} ${PASSWORD}"
|
|
||||||
read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" HOSTNAME
|
read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" HOSTNAME
|
||||||
|
|
||||||
tmpdir=$(mktemp -d)
|
tmpdir=$(mktemp -d)
|
||||||
@@ -40,7 +43,7 @@ if [ -x /usr/bin/dpkg ]; then
|
|||||||
if dpkg -l check-mk-agent > /dev/null; then
|
if dpkg -l check-mk-agent > /dev/null; then
|
||||||
dpkg -P check-mk-agent
|
dpkg -P check-mk-agent
|
||||||
fi
|
fi
|
||||||
apt-get install xinetd curl
|
apt-get install xinetd curl -y
|
||||||
dpkg -i ${tmpfile}
|
dpkg -i ${tmpfile}
|
||||||
# Apt
|
# Apt
|
||||||
wget -O /usr/lib/check_mk_agent/plugins/mk_apt http://${CHECK_MK_SERVER}/${SITE_NAME}/check_mk/agents/plugins/mk_apt
|
wget -O /usr/lib/check_mk_agent/plugins/mk_apt http://${CHECK_MK_SERVER}/${SITE_NAME}/check_mk/agents/plugins/mk_apt
|
||||||
@@ -100,7 +103,7 @@ fi
|
|||||||
|
|
||||||
/usr/bin/cmk-agent-ctl register --hostname ${HOSTNAME} \
|
/usr/bin/cmk-agent-ctl register --hostname ${HOSTNAME} \
|
||||||
--server ${CHECK_MK_SERVER} --site ${SITE_NAME} \
|
--server ${CHECK_MK_SERVER} --site ${SITE_NAME} \
|
||||||
--user ${USERNMAE} --password ${PASSWORD} \
|
--user ${USERNAME} --password ${PASSWORD} \
|
||||||
--trust-cert
|
--trust-cert
|
||||||
|
|
||||||
sleep 15s
|
sleep 15s
|
||||||
|
|||||||
5
csr.ps1
5
csr.ps1
@@ -9,7 +9,8 @@ param(
|
|||||||
[string]$domain = "home.johnhgaunt.com",
|
[string]$domain = "home.johnhgaunt.com",
|
||||||
[System.IO.FileInfo]$Path = [Environment]::GetFolderPath("Desktop"),
|
[System.IO.FileInfo]$Path = [Environment]::GetFolderPath("Desktop"),
|
||||||
[ValidateSet("RSA2048", "RSA4096","ECC-256", "ECC-384")]
|
[ValidateSet("RSA2048", "RSA4096","ECC-256", "ECC-384")]
|
||||||
[string]$algorithm = "ECC-384"
|
[string]$algorithm = "ECC-384",
|
||||||
|
[string]$server = "gauntonlineca.home.johnhgaunt.com\GauntOnlineCA-CA"
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
@@ -89,7 +90,7 @@ DNS.2 = $hostname"
|
|||||||
-Wait
|
-Wait
|
||||||
|
|
||||||
Start-Process certreq.exe `
|
Start-Process certreq.exe `
|
||||||
-ArgumentList "-submit -config `"gauntonlineca.home.johnhgaunt.com\GauntOnlineCA-CA`" -attrib `"$certReqAttrib`" `"$csrFile`" `"$crtFile`"" `
|
-ArgumentList "-submit -config `"$server`" -attrib `"$certReqAttrib`" `"$csrFile`" `"$crtFile`"" `
|
||||||
-Wait
|
-Wait
|
||||||
|
|
||||||
# add the sub CA to the end of the cert
|
# add the sub CA to the end of the cert
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ if [ "$EUID" -ne 0 ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
# ask for the domain, username, and password
|
# ask for the domain, username, and password
|
||||||
read -e -p "Enter Domain name: " -i "home.johnhgaunt.com" domain
|
read -e -p "Enter Domain Name: " -i "home.johnhgaunt.com" domain
|
||||||
read -e -p "Enter netBIOS name: " -i "GAUNT" netbiosname
|
read -e -p "Enter netBIOS Name: " -i "GAUNT" netbiosname
|
||||||
read -e -p "Enter Domain Admin username: " -i "jgaunto" username
|
read -e -p "Enter Domain Admin Username: " -i "jgaunto" username
|
||||||
read -e -s -p "Enter Password: " password
|
read -e -s -p "Enter ${USERNMAE}'s Password: " password
|
||||||
|
|
||||||
# get OS ditro and version
|
# get OS ditro and version
|
||||||
OS=$(hostnamectl | awk '/Operating System/ {print $3}')
|
OS=$(hostnamectl | awk '/Operating System/ {print $3}')
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
URL=${1}
|
|
||||||
EMAIL=${2}
|
|
||||||
NAME=${3}
|
|
||||||
|
|
||||||
LOG_FILE="/tmp/Ubiquiti Stock ${NAME}.log"
|
|
||||||
|
|
||||||
echo "" > "${LOG_FILE}"
|
|
||||||
|
|
||||||
echo "URL: ${URL}" | tee -a "${LOG_FILE}"
|
|
||||||
echo "Email: ${EMAIL}" | tee -a "${LOG_FILE}"
|
|
||||||
echo "Name: ${NAME}" | tee -a "${LOG_FILE}"
|
|
||||||
|
|
||||||
SOURCE_FILE="/tmp/Ubiquiti Stock ${NAME}.source"
|
|
||||||
|
|
||||||
echo "Source File: ${SOURCE_FILE}" | tee -a "${LOG_FILE}"
|
|
||||||
|
|
||||||
wget -qO "${SOURCE_FILE}" ${URL}
|
|
||||||
|
|
||||||
INVENTORY_QUANTITY=$(grep -o -m 1 '"inventory_quantity":[0-9]\+,' "${SOURCE_FILE}" | grep -o '[0-9]\+')
|
|
||||||
|
|
||||||
echo "Inventory Quantity: ${INVENTORY_QUANTITY}" | tee -a "${LOG_FILE}"
|
|
||||||
|
|
||||||
if [[ "${INVENTORY_QUANTITY}" -gt "0" ]]; then
|
|
||||||
MESSAGE="There are currently ${INVENTORY_QUANTITY} ${NAME} in stock. ${URL}"
|
|
||||||
echo "Message: ${MESSAGE}" | tee -a "${LOG_FILE}"
|
|
||||||
echo "${MESSAGE}" | mailx -r "stockalerts@johnhgaunt.com" --set smtp="smtp.home.johnhgaunt.com:25" "${EMAIL}"
|
|
||||||
echo "Email sent" | tee -a "${LOG_FILE}"
|
|
||||||
else
|
|
||||||
echo "Not sending email" | tee -a "${LOG_FILE}"
|
|
||||||
fi
|
|
||||||
Reference in New Issue
Block a user