diff --git a/debian/debian-essentials.sh b/debian/debian-essentials.sh index 39e90a3..f3e25fa 100755 --- a/debian/debian-essentials.sh +++ b/debian/debian-essentials.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + # autoreply config update dialog with no if [[ ! -f /etc/apt/apt.conf.d/local ]] then diff --git a/debian/debian-install-docker.sh b/debian/debian-install-docker.sh index c554b3b..d78502b 100755 --- a/debian/debian-install-docker.sh +++ b/debian/debian-install-docker.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + if [[ ! -f /etc/apt/keyrings/docker.gpg ]] then apt-get update diff --git a/debian/debian-install-samba.sh b/debian/debian-install-samba.sh index 8248f87..c0c8cd9 100755 --- a/debian/debian-install-samba.sh +++ b/debian/debian-install-samba.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + isInFile=$(cat /etc/samba/smb.conf | grep -c "akanealw") if [ $isInFile -eq 0 ] then diff --git a/debian/debian-regenerate-ssh-keys-machine-id.sh b/debian/debian-regenerate-ssh-keys-machine-id.sh index 1ab3845..1bb2b16 100644 --- a/debian/debian-regenerate-ssh-keys-machine-id.sh +++ b/debian/debian-regenerate-ssh-keys-machine-id.sh @@ -1,6 +1,12 @@ #!/bin/bash -# ask to regenerate machine-id +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + +# regenerate machine-id if [[ ! -f /etc/machine-id-regenerated ]] then rm -f /etc/machine-id /var/lib/dbus/machine-id @@ -12,7 +18,7 @@ if [[ ! -f /etc/machine-id-regenerated ]] echo "Machine-id not regenerated." fi -# ask to regenerate ssh host keys +# regenerate ssh host keys if [[ ! -d /etc/cloud ]] then if [[ ! -f /home/akanealw/.ssh/ssh_keys_regenerated ]] diff --git a/debian/debian-set-ip.sh b/debian/debian-set-ip.sh index 8147176..8ed03d0 100755 --- a/debian/debian-set-ip.sh +++ b/debian/debian-set-ip.sh @@ -1,6 +1,12 @@ #!/bin/bash -# ask to set static ip address +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + +# set static ip address if [[ ! -d /etc/cloud ]] then if [[ ! -f /etc/network/interfaces.bak ]] diff --git a/debian/debian-setup-email.sh b/debian/debian-setup-email.sh index 13aeed3..d62f761 100644 --- a/debian/debian-setup-email.sh +++ b/debian/debian-setup-email.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + isInFile=$(cat /etc/postfix/main.cf | grep -c "gmail") if [ $isInFile -eq 0 ] then diff --git a/debian/debian-setup-unattended-upgrades.sh b/debian/debian-setup-unattended-upgrades.sh index 67e6967..b8199ef 100644 --- a/debian/debian-setup-unattended-upgrades.sh +++ b/debian/debian-setup-unattended-upgrades.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + isInFile=$(cat /etc/apt/apt.conf.d/20auto-upgrades | grep -c 'APT::Periodic::Unattended-Upgrade "1";') if [ $isInFile -eq 0 ] then diff --git a/debian/debian-update-sources.sh b/debian/debian-update-sources.sh index e1b20d3..990c175 100644 --- a/debian/debian-update-sources.sh +++ b/debian/debian-update-sources.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + # update bookworm to new debian.sources file if [[ -f /etc/apt/sources.list.d/debian.sources ]] then diff --git a/ubuntu/ubuntu-essentials.sh b/ubuntu/ubuntu-essentials.sh index e8d8af0..d6e19ac 100755 --- a/ubuntu/ubuntu-essentials.sh +++ b/ubuntu/ubuntu-essentials.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + # disable restart prompt for services during an update if [[ ! -f /etc/needrestart/conf.d/no-prompt.conf ]] ; then echo "\$nrconf{restart} = 'a';" >> /etc/needrestart/conf.d/no-prompt.conf diff --git a/ubuntu/ubuntu-install-docker.sh b/ubuntu/ubuntu-install-docker.sh index bcb47e4..ef8a218 100755 --- a/ubuntu/ubuntu-install-docker.sh +++ b/ubuntu/ubuntu-install-docker.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + if [[ ! -f /etc/apt/keyrings/docker.gpg ]] then apt-get update diff --git a/ubuntu/ubuntu-install-samba.sh b/ubuntu/ubuntu-install-samba.sh index 7db3a3f..126a8d9 100755 --- a/ubuntu/ubuntu-install-samba.sh +++ b/ubuntu/ubuntu-install-samba.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + isInFile=$(cat /etc/samba/smb.conf | grep -c "akanealw") if [ $isInFile -eq 0 ] then diff --git a/ubuntu/ubuntu-regenerate-ssh-keys-machine-id.sh b/ubuntu/ubuntu-regenerate-ssh-keys-machine-id.sh index ca77dec..bc6ee0a 100644 --- a/ubuntu/ubuntu-regenerate-ssh-keys-machine-id.sh +++ b/ubuntu/ubuntu-regenerate-ssh-keys-machine-id.sh @@ -1,6 +1,12 @@ #!/bin/bash -# ask to regenerate machine-id +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + +# regenerate machine-id if [[ ! -f /etc/machine-id-regenerated ]] then rm -f /etc/machine-id /var/lib/dbus/machine-id @@ -12,7 +18,7 @@ if [[ ! -f /etc/machine-id-regenerated ]] echo "Machine-id not regenerated." fi -# ask to regenerate ssh host keys +# regenerate ssh host keys if [[ ! -d /etc/cloud ]] then if [[ ! -f /home/akanealw/.ssh/ssh_keys_regenerated ]] diff --git a/ubuntu/ubuntu-set-ip.sh b/ubuntu/ubuntu-set-ip.sh index 39cf16d..c280196 100755 --- a/ubuntu/ubuntu-set-ip.sh +++ b/ubuntu/ubuntu-set-ip.sh @@ -1,5 +1,12 @@ -# ask to set static ip address +#!/bin/bash +if [ "$EUID" -ne 0 ] + then + echo "Please run as root" + exit +fi + +# set static ip address if [[ ! -d /etc/cloud ]] then read -r -p "Enter Static IP Address with subnet prefix: " staticip