Compare commits

...

16 Commits

5 changed files with 84 additions and 29 deletions

View File

@@ -3,13 +3,13 @@
# CyberChef web directory
CYBERCHEF_DIRECTORY="/var/www/public/cyberchef"
# download srouce code of latest releases page
HTML_SOURCE=$(wget -O - https://api.github.com/repos/gchq/CyberChef/releases/latest)
CYBERCHEF_RELEASES_API=$(wget -O - https://api.github.com/repos/gchq/CyberChef/releases/latest)
# version
VERSION=$(echo ${HTML_SOURCE} | jq -r .tag_name)
VERSION=$(echo ${CYBERCHEF_RELEASES_API} | jq -r .tag_name)
# get download url
DOWNLOAD_URL=$(echo ${HTML_SOURCE} | jq -r .assets[].browser_download_url)
DOWNLOAD_URL=$(echo ${CYBERCHEF_RELEASES_API} | jq -r .assets[].browser_download_url)
# get filename
FILENAME=$(echo ${HTML_SOURCE} | jq -r .assets[].name)
FILENAME=$(echo ${CYBERCHEF_RELEASES_API} | jq -r .assets[].name)
# test if version is already downloaded
if [ $(ls ${CYBERCHEF_DIRECTORY}/*${VERSION}* | wc -l) -gt 0 ]; then

View File

@@ -58,6 +58,12 @@ chmod 600 "/etc/sssd/conf.d/${netbiosname}.conf"
systemctl restart sssd
# set the sudoers.d file for the server admins
echo "## ${netbiosname} Admins ##" > /etc/sudoers.d/${netbiosname}
echo "# Allow members of ${netbiosname}\Server Admins group sudo access" >> /etc/sudoers.d/${netbiosname}
echo "%Server\ Admins ALL=(ALL:ALL) ALL" >> /etc/sudoers.d/${netbiosname}
cat << EOF > /etc/sudoers.d/${netbiosname}
## ${netbiosname} Admins ##
# Allow members of ${netbiosname}\Domain Admins group sudo access
%Domain\ Admins ALL=(ALL:ALL) ALL
# Allow members of ${netbiosname}\Server Admins group sudo access
%Server\ Admins ALL=(ALL:ALL) ALL
EOF

50
scrutiny.sh Normal file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
# make sure we are running as sudo
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
# get OS ditro and version
OS=$(hostnamectl | awk '/Operating System/ {print $3}')
VM=$(hostnamectl | awk '/Virtualization/ {print $2}')
if [ ${OS} == 'Ubuntu' ]; then
OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $4}')
else
OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $5}')
fi
if [ "${VM}" == "vmware" ] || [ "${VM}" == "kvm" ] || [ "${VM}" == "lxc" ]; then
VM="true"
echo "This should only be installed with physical hosts"
exit
fi
# scrutiny web directory
SCRUTINY_DIRECTORY="/opt/scrutiny"
# download srouce code of latest releases page
HTML_SOURCE=$(wget -O - https://api.github.com/repos/AnalogJ/scrutiny/releases/latest)
# version
VERSION=$(echo ${HTML_SOURCE} | jq -r .tag_name)
# get assets
ASSETS=$(echo ${HTML_SOURCE} | jq -r .assets[])
if [ ! -d "${SCRUTINY_DIRECTORY}" ]; then
mkdir "${SCRUTINY_DIRECTORY}"
fi
jq -c .assets[] <<< ${HTML_SOURCE} | while read i; do
name=$(echo ${i} | jq -r .name)
downloadUrl=$(echo ${i} | jq -r .browser_download_url)
if [ ${name} == 'scrutiny-collector-metrics-linux-amd64' ]; then
wget -O "${SCRUTINY_DIRECTORY}/${name}" ${downloadUrl}
chmod +x "${SCRUTINY_DIRECTORY}/${name}"
cat << EOF > /etc/cron.daily/scrutiny
#!/bin/bash
"${SCRUTINY_DIRECTORY}/${name}" run --api-endpoint="http://gauntscrutiny.home.johnhgaunt.com:8080" --host-id $(hostname)
EOF
chmod +x /etc/cron.daily/scrutiny
/etc/cron.daily/scrutiny
fi
done

View File

@@ -22,16 +22,11 @@ else
OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $5}')
fi
if [ "${VIRTUALIZATION}" == "vmware" ]; then
if [ "${VIRTUALIZATION}" == "vmware" ] || [ "${VIRTUALIZATION}" == "kvm" ]; then
VM="true"
else
VM="false"
fi
if [ "${VIRTUALIZATION}" == "kvm" ]; then
KVM="true"
else
KVM="false"
fi
# set custom bash settings system wide
cat <<EOF > /etc/profile.d/gaunt_custom_bash.sh
@@ -49,7 +44,7 @@ if [ ${OS} == "Debian" ] || [ ${OS} == "Ubuntu" ]; then
apt update; apt upgrade -y
# install the packages on all systems
apt install -y apt-transport-https wget tar gnupg2 sudo dnsutils rsync nano htop nload iperf iperf3 unattended-upgrades unzip bzip2 git nfs-common uptimed net-tools build-essential curl realmd oddjob oddjob-mkhomedir sssd sssd-tools libnss-sss libpam-sss adcli mlocate ncdu wireguard clevis
apt install -y apt-transport-https wget tar gnupg2 sudo dnsutils rsync nano htop nload iperf iperf3 unattended-upgrades unzip bzip2 git nfs-common uptimed net-tools build-essential curl realmd oddjob oddjob-mkhomedir sssd sssd-tools libnss-sss libpam-sss adcli ncdu wireguard clevis jq
# enable unattended-upgrades
echo unattended-upgrades unattended-upgrades/enable_auto_updates boolean true | debconf-set-selections
@@ -67,6 +62,13 @@ if [ ${OS} == "Debian" ] || [ ${OS} == "Ubuntu" ]; then
apt install -y qemu-guest-agent
fi
# FastFetch install
#FASTFETCH_FILENAME="fastfetch-linux-amd64.deb"
# download srouce code of latest releases page
FASTFETCH_RELEASES_API=$(wget -O - https://api.github.com/repos/fastfetch-cli/fastfetch/releases/latest)
DOWNLOAD_URL=$(echo ${FASTFETCH_RELEASES_API} | jq -r '.assets[].browser_download_url | select(. | endswith("fastfetch-linux-amd64.deb"))')
wget -P /tmp ${DOWNLOAD_URL}
apt install --yes /tmp/fastfetch-linux-amd64.deb
# remove unneeded packages
apt autoremove -y
@@ -96,7 +98,7 @@ elif [ "${OS}" == "CentOS" ] || [ "${OS}" == "Rocky" ]; then
yum autoremove -y
# install the packages
yum install -y sudo rsync tar nano htop nload iperf iperf3 bind-utils yum-cron unzip bzip2 nfs-utils git wget uptimed net-tools make realmd oddjob oddjob-mkhomedir sssd adcli mlocate ncdu wireguard clevis
yum install -y sudo rsync tar nano htop nload iperf iperf3 bind-utils yum-cron unzip bzip2 nfs-utils git wget uptimed net-tools make realmd oddjob oddjob-mkhomedir sssd adcli ncdu wireguard clevis jq
# install vm tools
if [ "${VM}" == "true" ]; then
@@ -134,7 +136,7 @@ elif [ "${OS}" == "CentOS" ] || [ "${OS}" == "Rocky" ]; then
dnf autoremove -y
# install the packages
dnf install -y sudo rsync tar nano htop iperf3 bind-utils unzip bzip2 nfs-utils git wget net-tools make dnf-automatic realmd oddjob oddjob-mkhomedir sssd adcli mlocate ncdu wireguard clevis
dnf install -y sudo rsync tar nano htop iperf3 bind-utils unzip bzip2 nfs-utils git wget net-tools make dnf-automatic realmd oddjob oddjob-mkhomedir sssd adcli ncdu wireguard clevis jq
# enable automatic updates
sed --in-place "s/^apply_updates\ =\ no/apply_updates\ =\ yes/" /etc/dnf/automatic.conf
@@ -147,6 +149,15 @@ elif [ "${OS}" == "CentOS" ] || [ "${OS}" == "Rocky" ]; then
if [ "${KVM}" == "true" ]; then
dnf install -y qemu-guest-agent
fi
# FastFetch install
#FASTFETCH_FILENAME="fastfetch-linux-amd64.deb"
# download srouce code of latest releases page
FASTFETCH_RELEASES_API=$(wget -O - https://api.github.com/repos/fastfetch-cli/fastfetch/releases/latest)
DOWNLOAD_URL=$(echo ${FASTFETCH_RELEASES_API} | jq -r '.assets[].browser_download_url | select(. | endswith("fastfetch-linux-amd64.rpm"))')
wget -P /tmp ${DOWNLOAD_URL}
dnf install -y /tmp/fastfetch-linux-amd64.rpm
fi
# modify ssh to allow root login and then restart the service
@@ -176,17 +187,5 @@ else
git clone https://git.johnhgaunt.com/jgaunt/homelab-scripts
fi
# install neofetch
if [ -d /opt/neofetch ]; then
cd /opt/neofetch
git pull --ff-only
make install
else
cd /opt
git clone https://github.com/dylanaraps/neofetch
cd /opt/neofetch
make install
fi
# go to home directory
cd ~

View File

@@ -23,7 +23,7 @@ else
OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $5}')
fi
if [ "${VM}" == "vmware" ] || [ "${VM}" == "kvm" ] ; then
if [ "${VM}" == "vmware" ] || [ "${VM}" == "kvm" ] || [ "${VM}" == "lxc" ]; then
VM="true"
else
VM="false"