feat: add Fedora 44 bootstrap and shell customization scripts
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
swapoff -a
|
||||
sed -i "/swap/d" /etc/fstab
|
||||
|
||||
sysctl -w net/netfilter/nf_conntrack_max=131072
|
||||
|
||||
dnf -y install docker-compose
|
||||
|
||||
systemctl enable docker.service
|
||||
systemctl start docker.service
|
||||
|
||||
sleep 3
|
||||
@@ -0,0 +1,11 @@
|
||||
alias ls='ls --color=auto -hl --time-style long-iso'
|
||||
alias l='ls --color=auto -hlA --time-style long-iso'
|
||||
alias ll='ls --color=auto -hla --time-style long-iso'
|
||||
alias cd..='cd ..'
|
||||
alias ff='find / -name'
|
||||
alias f='find . -name'
|
||||
alias fif='grep -rnw . -e'
|
||||
alias grep='grep --color=auto'
|
||||
alias ip='ip -c'
|
||||
alias vdir='vdir --color=auto'
|
||||
alias watch='watch --color'
|
||||
@@ -0,0 +1,21 @@
|
||||
\v \r \l
|
||||
|
||||
.o oOOOOOOOo OOOo
|
||||
Ob.OOOOOOOo OOOo. oOOo. .adOOOOOOO
|
||||
OboO"""""""""""".OOo. .oOOOOOo. OOOo.oOOOOOo.."""""""""'OO
|
||||
OOP.oOOOOOOOOOOO "POOOOOOOOOOOo. `"OOOOOOOOOP,OOOOOOOOOOOB'
|
||||
`O'OOOO' `OOOOo"OOOOOOOOOOO` .adOOOOOOOOO"oOOO' `OOOOo
|
||||
.OOOO' `OOOOOOOOOOOOOOOOOOOOOOOOOO' `OO
|
||||
OOOOO '"OOOOOOOOOOOOOOOO"` oOO
|
||||
oOOOOOba. .adOOOOOOOOOOba .adOOOOo.
|
||||
oOOOOOOOOOOOOOba. .adOOOOOOOOOO@^OOOOOOOba. .adOOOOOOOOOOOO
|
||||
OOOOOOOOOOOOOOOOO.OOOOOOOOOOOOOO"` '"OOOOOOOOOOOOO.OOOOOOOOOOOOOO
|
||||
"OOOO" "YOoOOOOMOIONODOO"` . '"OOROAOPOEOOOoOY" "OOO"
|
||||
Y 'OOOOOOOOOOOOOO: .oOOo. :OOOOOOOOOOO?' :`
|
||||
: .oO%OOOOOOOOOOo.OOOOOO.oOOOOOOOOOOOO? .
|
||||
. oOOP"%OOOOOOOOoOOOOOOO?oOOOOO?OOOO"OOo
|
||||
'%o OOOO"%OOOO%"%OOOOO"OOOOOO"OOO':
|
||||
`$" `OOOO' `O"Y ' `OOOO' o .
|
||||
. . OP" : o .
|
||||
:
|
||||
.
|
||||
@@ -0,0 +1,5 @@
|
||||
clrreset='\e[0m'
|
||||
clrwhite='\e[1;37m'
|
||||
clrgreen='\e[1;32m'
|
||||
clrred='\e[1;31m'
|
||||
export PS1="\[$clrred\][$USER@$HOSTNAME]\[$clrwhite\] \w \`if [ \$? = 0 ]; then echo -e '\[$clrgreen\]'; else echo -e '\[$clrred\]'; fi\`\\$ \[$clrreset\]"
|
||||
@@ -0,0 +1,191 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare BASE_URL=https://git.netm.ch/m/os-init/raw/branch/main
|
||||
declare DIR_URL=fedora-44
|
||||
IPV4=127.0.0.1
|
||||
|
||||
showHelp() {
|
||||
echo "init.sh"
|
||||
echo ""
|
||||
echo "usage :"
|
||||
echo "bash init.sh [options]"
|
||||
echo " -b | --base-url url"
|
||||
}
|
||||
|
||||
InitConst() {
|
||||
IPV4=$(ip addr | grep 'inet ' | grep -v '127.0' | head -n1 | awk '{print $2}' | cut -f1 -d /)
|
||||
}
|
||||
|
||||
Main() {
|
||||
InitConst
|
||||
NetSetHostname
|
||||
NetIPConfig
|
||||
#DNFSetProxy
|
||||
DNFUpdateDist
|
||||
DNFInstallBase
|
||||
DNFCleanAll
|
||||
BashSetAlias
|
||||
BashSetPS
|
||||
NanoSetConfig
|
||||
IssueSetContent
|
||||
SSHEnableRootLogin
|
||||
GrubSetConfig
|
||||
InstApps
|
||||
Reboot
|
||||
}
|
||||
|
||||
NetSetHostname() {
|
||||
hostname=$(hostname)
|
||||
hostname=$(whiptail --title "Hostname + Domain" --inputbox "" 0 30 "${hostname}" 3>&1 1>&2 2>&3)
|
||||
# shellcheck disable=SC2181
|
||||
if [ "$?" = "0" ] && [ "${hostname}" != "" ]; then
|
||||
hostnamectl set-hostname "${hostname}"
|
||||
fi
|
||||
}
|
||||
NetIPConfig() {
|
||||
options=()
|
||||
options+=("DHCP" "")
|
||||
options+=("Static" "")
|
||||
sel=$(whiptail --title "Network" --menu "" 0 0 0 "${options[@]}" 3>&1 1>&2 2>&3)
|
||||
# shellcheck disable=SC2181
|
||||
if [ "$?" = "0" ]; then
|
||||
case ${sel} in
|
||||
"Static") NetIPConfigStatic;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
NetIPConfigStatic() {
|
||||
netif="$(ip a | grep ens | head -n1 | cut -d: -f2)"
|
||||
netif=${netif:1}
|
||||
netip="${IPV4}"
|
||||
netmask="255.255.255.0"
|
||||
netgw="$(echo "${IPV4}" | cut -d. -f1-3).1"
|
||||
netdns="$(echo "${IPV4}" | cut -d. -f1-3).1"
|
||||
netip=$(whiptail --title "Network" --inputbox "IP" 0 30 "${netip}" 3>&1 1>&2 2>&3)
|
||||
# shellcheck disable=SC2181
|
||||
if [ "$?" = "0" ] && [ "${netip}" != "" ]; then
|
||||
netmask=$(whiptail --title "Network" --inputbox "Mask" 0 30 "${netmask}" 3>&1 1>&2 2>&3)
|
||||
if [ "$?" = "0" ] && [ "${netmask}" != "" ]; then
|
||||
netgw=$(whiptail --title "Network" --inputbox "Route" 0 30 "${netgw}" 3>&1 1>&2 2>&3)
|
||||
if [ "$?" = "0" ] && [ "${netgw}" != "" ]; then
|
||||
netdns=$(whiptail --title "Network" --inputbox "DNS" 0 30 "${netdns}" 3>&1 1>&2 2>&3)
|
||||
if [ "$?" = "0" ] && [ "${netdns}" != "" ]; then
|
||||
echo "Not implemented"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
DNFUpdateDist() {
|
||||
dnf -y upgrade
|
||||
}
|
||||
DNFInstallBase() {
|
||||
options=()
|
||||
options+=("curl" "" on)
|
||||
options+=("wget" "" on)
|
||||
options+=("lsof" "" on)
|
||||
options+=("bash-completion" "" on)
|
||||
options+=("nano" "" on)
|
||||
options+=("openssh-server" "" on)
|
||||
options+=("gnupg" "" on)
|
||||
options+=("rsync" "" on)
|
||||
options+=("nmon" "" on)
|
||||
options+=("snmpd" "" on)
|
||||
sel=$(whiptail --title "Basic Install" --checklist "" 0 0 0 "${options[@]}" 3>&1 1>&2 2>&3)
|
||||
# shellcheck disable=SC2181
|
||||
if [ "$?" = "0" ]; then
|
||||
pkg=""
|
||||
for itm in ${sel}; do
|
||||
pkg="${pkg} $(echo "${itm}" | sed 's/"//g')";;
|
||||
done
|
||||
# shellcheck disable=SC2086
|
||||
dnf -y install ${pkg}
|
||||
for itm in ${sel}; do
|
||||
case ${itm} in
|
||||
'"snmpd"')
|
||||
SNMPDConfig;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
DNFCleanAll() {
|
||||
dnf -y autoremove
|
||||
}
|
||||
|
||||
BashSetAlias() {
|
||||
wget -O /etc/profile.d/alias.sh "${BASE_URL}"/"${DIR_URL}"/files/alias.sh
|
||||
}
|
||||
BashSetPS() {
|
||||
wget -O /etc/profile.d/ps1.sh "${BASE_URL}"/"${DIR_URL}"/files/ps1.sh
|
||||
}
|
||||
|
||||
NanoSetConfig() {
|
||||
sed -i "/tabsize/c\set tabsize 2" /etc/nanorc
|
||||
{
|
||||
echo "set numbercolor brightwhite"
|
||||
echo "set statuscolor brightwhite,green"
|
||||
echo "set keycolor cyan"
|
||||
echo "set functioncolor green"
|
||||
} >> /etc/nanorc
|
||||
{
|
||||
echo "set titlecolor brightwhite,red"
|
||||
echo "set statuscolor brightwhite,red"
|
||||
} > /root/.nanorc
|
||||
}
|
||||
|
||||
IssueSetContent() {
|
||||
wget -O /etc/issue "${BASE_URL}"/"${DIR_URL}"/files/issue
|
||||
}
|
||||
|
||||
SNMPDConfig() {
|
||||
cummunityname=public
|
||||
cummunityname=$(whiptail --title "SNMP Community name" --inputbox "" 0 30 "${cummunityname}" 3>&1 1>&2 2>&3)
|
||||
sed -i "s/public/${cummunityname}/" /etc/snmp/snmpd.conf
|
||||
sed -i "s/127.0.0.1,\[::1\]/0.0.0.0/" /etc/snmp/snmpd.conf
|
||||
systemctl restart snmpd
|
||||
}
|
||||
|
||||
SSHEnableRootLogin() {
|
||||
sed -i "/PermitRootLogin prohibit-password/c\PermitRootLogin yes #prohibit-password" /etc/ssh/sshd_config
|
||||
systemctl restart sshd
|
||||
}
|
||||
|
||||
GrubSetConfig() {
|
||||
if [ -f "/etc/default/grub" ]; then
|
||||
sed -i "/GRUB_TIMEOUT/c\GRUB_TIMEOUT=1" /etc/default/grub
|
||||
update-grub
|
||||
fi
|
||||
}
|
||||
|
||||
InstApps() {
|
||||
options=()
|
||||
options+=("docker" "" off)
|
||||
SEL=$(whiptail --title "More Apps" --checklist "" 0 0 0 "${options[@]}" 3>&1 1>&2 2>&3)
|
||||
# shellcheck disable=SC2181
|
||||
if [ "$?" = "0" ]; then
|
||||
for ITM in ${SEL}; do
|
||||
case ${ITM//\"/} in
|
||||
*)
|
||||
cd /tmp || exit
|
||||
wget "${BASE_URL}"/${DIR_URL}/apps/"${ITM//\"/}"/"${ITM//\"/}".sh
|
||||
bash ./"${ITM//\"/}".sh "${BASE_URL}"/${DIR_URL}/apps/"${ITM//\"/}";;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
Reboot() {
|
||||
if whiptail --yesno "Reboot ?" 0 0 3>&1 1>&2 2>&3; then
|
||||
reboot
|
||||
fi
|
||||
}
|
||||
|
||||
while [ ${#} -gt 0 ]; do
|
||||
case ${1} in
|
||||
--help) showHelp; exit 0;;
|
||||
-b | --base-url) BASE_URL="${2}"; shift;;
|
||||
*) shift;;
|
||||
esac
|
||||
done
|
||||
|
||||
Main
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare BASE_URL=https://git.netm.ch/m/os-init/raw/branch/main
|
||||
declare FEDORAVER=0
|
||||
|
||||
showHelp() {
|
||||
echo "fedora.sh"
|
||||
echo ""
|
||||
echo "use :"
|
||||
echo "bash fedora.sh [options]"
|
||||
echo " -b | --base-url url"
|
||||
}
|
||||
|
||||
main() {
|
||||
FEDORAVER=$(grep "VERSION_ID=" /etc/os-release | sed 's/"//g' | sed 's/.*=//')
|
||||
dnf -y upgrade
|
||||
dnf -y install wget newt
|
||||
wget -O /tmp/init.sh "${BASE_URL}"/fedora-"${FEDORAVER}"/init.sh
|
||||
bash /tmp/init.sh -b "${BASE_URL}"
|
||||
rm /tmp/init.sh
|
||||
}
|
||||
|
||||
|
||||
while [ ${#} -gt 0 ]; do
|
||||
case ${1} in
|
||||
--help) showHelp; exit 0;;
|
||||
-b | --base-url) BASE_URL="${2}"; shift;;
|
||||
*) shift;;
|
||||
esac
|
||||
done
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user