Skip to content

Instantly share code, notes, and snippets.

@saudiqbal
Last active August 30, 2025 18:34
Show Gist options
  • Select an option

  • Save saudiqbal/cd6a10f2af36d2331c22a2fb99dea2be to your computer and use it in GitHub Desktop.

Select an option

Save saudiqbal/cd6a10f2af36d2331c22a2fb99dea2be to your computer and use it in GitHub Desktop.
Kubuntu Setup
#!/bin/bash
RD=$(echo "\033[01;31m")
YW=$(echo "\033[33m")
GN=$(echo "\033[1;92m")
CL=$(echo "\033[m")
BFR="\\r\\033[K"
HOLD="+"
CM="${GN}✓${CL}"
CROSS="${RD}✗${CL}"
msg_info() {
local msg="$1"
echo -e " ${HOLD} ${YW}${msg}${CL}"
}
msg_ok() {
local msg="$1"
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
}
msg_error() {
local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
}
clear
echo "=========================================="
echo "=========== Kubuntu Setup =============="
echo "=========================================="
get_opsy(){
[ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
}
get_os_info(){
local cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
local cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
local freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
local tram=$( free -m | awk '/Mem/ {print $2}' )
local swap=$( free -m | awk '/Swap/ {print $2}' )
local up=$( awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60;d=$1%60} {printf("%ddays, %d:%d:%d\n",a,b,c,d)}' /proc/uptime )
local load=$( w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
local opsy=$( get_opsy )
local arch=$( uname -m )
local lbit=$( getconf LONG_BIT )
local host=$( hostname )
local kern=$( uname -r )
echo "########## System Information ##########"
echo
echo "CPU model : ${cname}"
echo "Number of cores : ${cores}"
echo "CPU frequency : ${freq} MHz"
echo "Total amount of ram : ${tram} MB"
echo "Total amount of swap : ${swap} MB"
echo "System uptime : ${up}"
echo "Load average : ${load}"
echo "OS : ${opsy}"
echo "Arch : ${arch} (${lbit} Bit)"
echo "Kernel : ${kern}"
echo "Hostname : ${host}"
echo "########################################"
}
get_os_info
echo -n "Start Kubuntu Setup? [y/N]? "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
echo "Starting Kubuntu setup"
else
echo "Exiting Kubuntu setup"
exit
fi
sleep 1
echo -n "Change Journal storage to RAM [y/N]? "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
sudo sed -i -e "s?#Storage=auto?Storage=volatile?g" /etc/systemd/journald.conf
sudo sed -i -e "s?#SystemMaxUse=?SystemMaxUse=25M?g" /etc/systemd/journald.conf
sudo systemctl restart systemd-journald.service
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
sudo rm -r /var/log/journal/*
msg_ok "Journal configured!"
else
msg_info "Skipped"
fi
echo -n "Download custom Dolphin toolbar [y/N]? "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
mkdir -p "$HOME/.local/share/kxmlgui5/dolphin"
curl https://gist.githubusercontent.com/saudiqbal/7e6e8a90444c3213203acbf263bea6ce/raw/dolphinui.rc -o "$HOME/.local/share/kxmlgui5/dolphin/dolphinui.rc"
msg_ok "Dolphin toolbar configured!"
else
msg_info "Skipped"
fi
echo -n "Change Fstrim schedule to daily [y/N]? "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
sudo sed -i -e "s?OnCalendar=weekly?OnCalendar=daily?g" /usr/lib/systemd/system/fstrim.timer
sudo systemctl daemon-reload
msg_ok "Fstrim schedule changed to daily!"
else
msg_info "Skipped"
fi
echo -n "do-release-upgrade keep third party sources enabled on upgrades [y/N]? "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
sudo tee -a /etc/update-manager/release-upgrades.d/AllowThirdPartyPPA.cfg >/dev/null <<'EOF'
[Sources]
AllowThirdParty = yes
EOF
msg_ok "Third party PPA enabled for upgrade!"
else
msg_info "Skipped"
fi
echo -n "Keep release source on normal [y/N]? "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
sudo tee -a /etc/cron.daily/KeepSourceNormal >/dev/null <<'EOF'
#!/bin/bash
STATUS="$(grep "^Prompt=" /etc/update-manager/release-upgrades | awk -F'=' '{print $2}')"
if [ "${STATUS}" != "normal" ]; then
logger -t SystemAdmin -p warning "[ S Y S T E M A D M I N ] release upgrade changed to normal"
sudo sed -i 's/^\(Prompt=\).*$/\1normal/' /etc/update-manager/release-upgrades
fi
exit 0
EOF
sudo chmod +x /etc/cron.daily/KeepSourceNormal
msg_ok "Release schedule changed to normal!"
else
msg_info "Skipped"
fi
echo -n "Delete setup file [y/N]? "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
rm setup.sh
#echo "Deleted!"
msg_ok "Setup file deleted!"
else
msg_info "Skipped"
fi
sleep 1
clear
echo "=========================================="
echo "========== Kubuntu Setup Done =========="
echo "=========================================="
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment