first commit
This commit is contained in:
17
ubuntu/download-ubuntu-essentials.sh
Executable file
17
ubuntu/download-ubuntu-essentials.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ -d /home/akanealw ]]
|
||||
then
|
||||
rm /home/akanealw/scripts/ubuntu-essentials* > /dev/null 2>&1
|
||||
rm /root/scripts/ubuntu-essentials* > /dev/null 2>&1
|
||||
mkdir /home/akanealw/scripts > /dev/null 2>&1
|
||||
wget -qO /home/akanealw/scripts/ubuntu-essentials.sh https://aknlw.com/ubuntu-essentials
|
||||
chmod +x /home/akanealw/scripts/ubuntu-essentials.sh
|
||||
sudo /home/akanealw/scripts/ubuntu-essentials.sh
|
||||
else
|
||||
rm /root/scripts/ubuntu-essentials* > /dev/null 2>&1
|
||||
mkdir /root/scripts > /dev/null 2>&1
|
||||
wget -qO /root/scripts/ubuntu-essentials.sh https://aknlw.com/ubuntu-essentials
|
||||
chmod +x /root/scripts/ubuntu-essentials.sh
|
||||
/root/scripts/ubuntu-essentials.sh
|
||||
fi
|
||||
120
ubuntu/ubuntu-essentials.sh
Executable file
120
ubuntu/ubuntu-essentials.sh
Executable file
@@ -0,0 +1,120 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
# update and upgrade
|
||||
apt-get update
|
||||
apt-get upgrade -y
|
||||
|
||||
# download and install packages
|
||||
apt-get install -y pwgen qemu-guest-agent sudo nano curl wget zip unzip git rsync man-db cifs-utils nfs-common parted libtalloc2 libwbclient0 net-tools gnupg apt-transport-https tmux gdisk bash-completion
|
||||
|
||||
# add akanealw user if not existing
|
||||
isInFile=$(cat /etc/passwd | grep -c "akanealw")
|
||||
if [ $isInFile -eq 0 ]; then
|
||||
echo "Set password for akanealw"
|
||||
useradd -m -p $(openssl passwd -1 ${PASSWORD}) -s /bin/bash -d /home/akanealw akanealw
|
||||
mkdir /home/akanealw/.ssh
|
||||
chown akanealw:akanealw /home/akanealw/.ssh
|
||||
chmod 700 /home/akanealw/.ssh
|
||||
cp /root/.ssh/authorized_keys /home/akanealw/.ssh > /dev/null 2>&1
|
||||
chown akanealw:akanealw /home/akanealw/.ssh/authorized_keys > /dev/null 2>&1
|
||||
chmod 600 /home/akanealw/.ssh/authorized_keys > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
# create akanealw file in /etc/sudoers.d
|
||||
if [[ ! -f /etc/sudoers.d/akanealw ]] ; then
|
||||
echo "akanealw ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/akanealw
|
||||
fi
|
||||
|
||||
# enable ping for all users
|
||||
setcap 'cap_net_admin,cap_net_raw+ep' $(which ping)
|
||||
|
||||
# remove all motd
|
||||
apt-get remove --purge update-motd > /dev/null 2>&1
|
||||
rm /etc/default/motd-news > /dev/null 2>&1
|
||||
rm -r /etc/update-motd.d > /dev/null 2>&1
|
||||
rm /etc/motd > /dev/null 2>&1
|
||||
|
||||
# git config
|
||||
git config --global credential.helper store
|
||||
git config --global user.name "akanealw"
|
||||
git config --global user.email "akanealw@gmail.com"
|
||||
git config --global init.defaultBranch main
|
||||
|
||||
# show ip in /etc/issue
|
||||
wget -qO /etc/issue.default http://192.168.1.50/ubuntu/issue.default
|
||||
rm /etc/issue > /dev/null 2>&1
|
||||
rm /etc/issue.bak > /dev/null 2>&1
|
||||
cp /etc/issue.default /etc/issue
|
||||
name=$(basename /sys/class/net/e*)
|
||||
echo "" >> /etc/issue
|
||||
echo "$name: \4{$name}" >> /etc/issue
|
||||
echo "" >> /etc/issue
|
||||
|
||||
# set input preferences
|
||||
wget -qO /etc/inputrc.default http://192.168.1.50/ubuntu/inputrc.default
|
||||
rm /etc/inputrc > /dev/null 2>&1
|
||||
rm /etc/inputrc.bak > /dev/null 2>&1
|
||||
cp /etc/inputrc.default /etc/inputrc
|
||||
echo "" >> /etc/inputrc
|
||||
echo "set completion-ignore-case On" >> /etc/inputrc
|
||||
|
||||
# set bash preferences and aliases
|
||||
wget -qO /etc/bash.bashrc.default http://192.168.1.50/ubuntu/bash.bashrc.default
|
||||
rm /etc/bash.bashrc > /dev/null 2>&1
|
||||
rm /etc/bash.bashrc.bak > /dev/null 2>&1
|
||||
cp /etc/bash.bashrc.default /etc/bash.bashrc
|
||||
echo "" >> /etc/bash.bashrc
|
||||
echo "# custom settings and aliases" >> /etc/bash.bashrc
|
||||
echo "set -o noclobber" >> /etc/bash.bashrc
|
||||
echo "alias lsa='ls -alhvF'" >> /etc/bash.bashrc
|
||||
echo "alias systart='sudo systemctl start'" >> /etc/bash.bashrc
|
||||
echo "alias systop='sudo systemctl stop'" >> /etc/bash.bashrc
|
||||
echo "alias sysrest='sudo systemctl restart'" >> /etc/bash.bashrc
|
||||
echo "alias systat='sudo systemctl status'" >> /etc/bash.bashrc
|
||||
echo "alias aptupy='sudo apt update && sudo apt upgrade -y'" >> /etc/bash.bashrc
|
||||
echo "alias aptiy='sudo apt install -y'" >> /etc/bash.bashrc
|
||||
echo "alias aptry='sudo apt remove -y'" >> /etc/bash.bashrc
|
||||
echo "alias aptrpy='sudo apt remove --purge -y'" >> /etc/bash.bashrc
|
||||
echo "alias aptary='sudo apt autoremove -y'" >> /etc/bash.bashrc
|
||||
echo "alias apts='sudo apt search'" >> /etc/bash.bashrc
|
||||
echo "alias aptl='sudo apt list --installed'" >> /etc/bash.bashrc
|
||||
echo "alias aptsh='sudo apt show'" >> /etc/bash.bashrc
|
||||
echo "alias aptac='sudo apt-get autoclean'" >> /etc/bash.bashrc
|
||||
echo "alias dpkgi='sudo dpkg -i'" >> /etc/bash.bashrc
|
||||
echo "alias tmxls='tmux ls'" >> /etc/bash.bashrc
|
||||
echo "alias tmxa='tmux attach -t'" >> /etc/bash.bashrc
|
||||
echo "alias dckr='ssh akanealw@192.168.1.30'" >> /etc/bash.bashrc
|
||||
echo "alias ipbs='ssh akanealw@192.168.1.50'" >> /etc/bash.bashrc
|
||||
echo "alias pihl='ssh akanealw@192.168.1.5'" >> /etc/bash.bashrc
|
||||
echo "alias pmbs='ssh root@192.168.1.40'" >> /etc/bash.bashrc
|
||||
echo "alias pmx1='ssh root@192.168.1.51'" >> /etc/bash.bashrc
|
||||
echo "alias tnas='ssh root@192.168.1.41'" >> /etc/bash.bashrc
|
||||
echo "alias dc='docker compose'" >> /etc/bash.bashrc
|
||||
echo "alias dcup='docker compose up -d'" >> /etc/bash.bashrc
|
||||
echo "alias dcaup='docker compose -f admin-compose.yml up -d'" >> /etc/bash.bashrc
|
||||
echo "alias dcdown='docker compose down'" >> /etc/bash.bashrc
|
||||
echo "alias dcadown='docker compose -f admin-compose.yml down'" >> /etc/bash.bashrc
|
||||
echo "alias dcpull='docker compose pull'" >> /etc/bash.bashrc
|
||||
echo "alias dcapull='docker compose -f admin-compose.yml pull'" >> /etc/bash.bashrc
|
||||
echo "alias dps='docker ps'" >> /etc/bash.bashrc
|
||||
echo "alias dipaf='docker image prune -a -f'" >> /etc/bash.bashrc
|
||||
|
||||
# create tmux config
|
||||
rm /etc/tmux.conf* > /dev/null 2>&1
|
||||
echo "unbind C-b" >> /etc/tmux.conf
|
||||
echo "set-option -g prefix C-a" >> /etc/tmux.conf
|
||||
echo "bind-key C-a send-prefix" >> /etc/tmux.conf
|
||||
|
||||
# create credentials and map network drives
|
||||
isInFile=$(cat /etc/fstab | grep -c "192.168.1.41")
|
||||
if [ $isInFile -eq 0 ]; then
|
||||
mkdir /mnt/truenasdata > /dev/null 2>&1
|
||||
chown akanealw:akanealw /mnt/truenasdata
|
||||
echo "# nfs shares" >> /etc/fstab
|
||||
echo "192.168.1.41:/mnt/data /mnt/truenasdata nfs defaults,nolock,soft,vers=4.2 0 0" >> /etc/fstab
|
||||
fi
|
||||
23
ubuntu/ubuntu-install-docker.sh
Executable file
23
ubuntu/ubuntu-install-docker.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ ! -f /etc/apt/keyrings/docker.gpg ]]
|
||||
then
|
||||
apt-get update
|
||||
apt-get install -y ca-certificates curl gnupg lsb-release
|
||||
chown -R akanealw:akanealw /home/akanealw/docker
|
||||
mkdir -m 0755 -p /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
apt-get update
|
||||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
groupadd docker > /dev/null 2>&1
|
||||
usermod -aG docker akanealw
|
||||
systemctl enable docker.service
|
||||
systemctl enable containerd.service
|
||||
systemctl start docker.service
|
||||
systemctl start containerd.service
|
||||
systemctl status docker.service
|
||||
systemctl status containerd.service
|
||||
else
|
||||
echo "Docker is already configured."
|
||||
fi
|
||||
19
ubuntu/ubuntu-install-samba.sh
Executable file
19
ubuntu/ubuntu-install-samba.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
isInFile=$(cat /etc/samba/smb.conf | grep -c "akanealw")
|
||||
if [ $isInFile -eq 0 ]
|
||||
then
|
||||
apt-get install -y samba --no-install-recommends
|
||||
(echo "8ung1e1!"; sleep 1; echo "8ung1e1!" ) | smbpasswd -s -a akanealw
|
||||
sed -i s/WORKGROUP/akanealw/ /etc/samba/smb.conf
|
||||
echo "[akanealw]" >> /etc/samba/smb.conf
|
||||
echo " comment = akanealw" >> /etc/samba/smb.conf
|
||||
echo " read only = no" >> /etc/samba/smb.conf
|
||||
echo " path = /home/akanealw" >> /etc/samba/smb.conf
|
||||
echo " guest ok = no" >> /etc/samba/smb.conf
|
||||
echo "" >> /etc/samba/smb.conf
|
||||
systemctl restart smbd
|
||||
systemctl status smbd
|
||||
else
|
||||
echo "Samba is already configured."
|
||||
fi
|
||||
32
ubuntu/ubuntu-regenerate-ssh-keys-machine-id.sh
Normal file
32
ubuntu/ubuntu-regenerate-ssh-keys-machine-id.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ask to regenerate machine-id
|
||||
if [[ ! -f /etc/machine-id-regenerated ]]
|
||||
then
|
||||
read -r -p "Regenerate machine-id? <y/N> " prompt
|
||||
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]
|
||||
then
|
||||
rm -f /etc/machine-id /var/lib/dbus/machine-id
|
||||
dbus-uuidgen --ensure=/etc/machine-id
|
||||
dbus-uuidgen --ensure
|
||||
touch /etc/machine-id-regenerated
|
||||
fi
|
||||
fi
|
||||
|
||||
# ask to regenerate ssh host keys
|
||||
if [[ ! -d /etc/cloud ]]
|
||||
then
|
||||
if [[ ! -f /home/akanealw/.ssh/ssh_keys_regenerated ]]
|
||||
then
|
||||
read -r -p "Regenerate SSH Keys? <y/N> " prompt
|
||||
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]
|
||||
then
|
||||
rm /etc/ssh/ssh_host_*
|
||||
dpkg-reconfigure openssh-server
|
||||
mkdir /home/akanealw/.ssh
|
||||
touch /home/akanealw/.ssh/ssh_keys_regenerated
|
||||
chmod 700 /home/akanealw/.ssh
|
||||
chown -R akanealw:akanealw /home/akanealw/.ssh
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
29
ubuntu/ubuntu-set-ip.sh
Executable file
29
ubuntu/ubuntu-set-ip.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
# ask to set static ip address
|
||||
read -r -p "Set Static IP address? <y/N> " prompt
|
||||
if [[ "${prompt,,}" =~ ^(y|yes)$ ]] ; then
|
||||
read -r -p "Enter Static IP Address with subnet prefix: " staticip
|
||||
read -r -p "Enter Gateway IP Address: " gatewayip
|
||||
read -r -p "Enter DNS IP Address (separated by commas): " dnsip
|
||||
# get adapter name
|
||||
name=$(basename /sys/class/net/e*)
|
||||
# backup original netplan yaml file
|
||||
mv /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak > /dev/null 2>&1
|
||||
rm /etc/netplan/01-network-manager-all.yaml > /dev/null 2>&1
|
||||
# create new netplan yaml file
|
||||
cat >> /etc/netplan/01-network-manager-all.yaml <<HERE
|
||||
network:
|
||||
version: 2
|
||||
renderer: networkd
|
||||
ethernets:
|
||||
$name:
|
||||
addresses:
|
||||
- $staticip
|
||||
nameservers:
|
||||
addresses: [$dnsip]
|
||||
routes:
|
||||
- to: default
|
||||
via: $gatewayip
|
||||
HERE
|
||||
# apply netplan
|
||||
sudo netplan apply
|
||||
fi
|
||||
Reference in New Issue
Block a user