2018-03-21 07:26:38 +00:00
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# Yggdrasil NG #
|
|
|
|
# compatibility : Mint 18, Ubuntu 16.04, Elementary and other derivatives #
|
|
|
|
# author : Francois B. (Makotosan/Shakasan) #
|
|
|
|
# licence : GPLv3 #
|
|
|
|
# website : https://makotonoblog.be/ #
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# tools and config functions #
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
#
|
|
|
|
# enable ufw at boot time and add rules for installed apps
|
|
|
|
#
|
|
|
|
function enableUFW () {
|
|
|
|
msg "Enabling FireWall (UFW)"
|
|
|
|
runCmd "sudo ufw enable"\
|
|
|
|
"enabling UFW at boot"
|
|
|
|
|
|
|
|
if which syncthing >/dev/null; then
|
|
|
|
runCmd "sudo ufw allow syncthing" \
|
|
|
|
"adding UFW rules for Syncthing"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# enable numlock by default on LightDM
|
|
|
|
#
|
|
|
|
function enableNumLockX () {
|
|
|
|
msg "Adding NumLockX to MDM/LightDM Default Init"
|
|
|
|
checkAndInstallDep apt numlockx numlockx
|
|
|
|
if which lightdm >/dev/null; then
|
|
|
|
runCmd "sudo cp /etc/lightdm/lightdm.conf.d/70-linuxmint.conf /etc/lightdm/lightdm.conf.d/70-linuxmint.conf.yggbak" \
|
2018-03-21 07:31:17 +00:00
|
|
|
"Backing up original config file"
|
2018-03-21 07:26:38 +00:00
|
|
|
runCmd "echo -e '\ngreeter-setup-script=/usr/bin/numlockx on' | sudo tee -a /etc/lightdm/lightdm.conf.d/70-linuxmint.conf" \
|
2018-03-21 07:31:17 +00:00
|
|
|
"Enabling numlockx on in lightdm at boot"
|
2018-03-21 07:26:38 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# /tmp in RAM by modifying /etc/fstab
|
2018-03-24 16:08:59 +00:00
|
|
|
#TODO: add possibily to choose amount of ram
|
2018-03-21 07:26:38 +00:00
|
|
|
function enableTmpRAM () {
|
|
|
|
runCmd "echo 'tmpfs /tmp tmpfs defaults,size=2g 0 0' | sudo tee -a /etc/fstab" \
|
2018-03-21 07:31:17 +00:00
|
|
|
"Enabling /tmp in RAM by modifying /etc/fstab"
|
2018-03-21 07:26:38 +00:00
|
|
|
if (whiptail --title "/tmp in RAM - Reboot" --yesno "Reboot required, proceed now ?" 10 60) then
|
|
|
|
sudo reboot
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# add screenfetch exec in .bashrc
|
|
|
|
#
|
|
|
|
function addScreenfetchBashrc () {
|
|
|
|
msg "Adding screenfetch to .bashrc"
|
|
|
|
checkAndInstallDep apt screenfetch screenfetch
|
|
|
|
runCmd "touch /home/$myHomedir/.bashrc" \
|
2018-03-21 07:31:17 +00:00
|
|
|
"Creating .bashrc file if necessary"
|
2018-03-21 07:26:38 +00:00
|
|
|
runCmd "echo 'screenfetch -t' | tee -a /home/$myHomedir/.bashrc" \
|
2018-03-21 07:31:17 +00:00
|
|
|
"Adding screenfetch to .bashrc"
|
2018-03-21 07:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# cli history cmd timestamp enable
|
|
|
|
#
|
|
|
|
function enableHistoryTS () {
|
|
|
|
typeset ret_code
|
|
|
|
printf "Enabling CLI History TimeStamp "
|
|
|
|
echo "export HISTTIMEFORMAT='%F %T '" | tee -a /home/$myHomedir/.bashrc &>> $logFile
|
|
|
|
ret_code=$?
|
|
|
|
retCode $ret_code
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# install/enable auto install of security updates
|
|
|
|
#
|
|
|
|
function installUnattendedUpgrades () {
|
|
|
|
msg "Installing unattended-upgrades"
|
|
|
|
installPackage apt "unattended-upgrades"
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# display useful system/hardware informations
|
|
|
|
#
|
|
|
|
function toolInxi () {
|
2018-03-21 07:31:17 +00:00
|
|
|
checkAndInstallDep apt inxi inxi \
|
|
|
|
&& inxi -F
|
2018-03-21 07:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# check bandwith and latency of the internet connection
|
|
|
|
#
|
|
|
|
function toolSpeedtestCli () {
|
2018-03-21 07:31:17 +00:00
|
|
|
checkAndInstallDep pip speedtest-cli speedtest-cli \
|
|
|
|
&& speedtest-cli
|
2018-03-21 07:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# check for packet loss
|
|
|
|
#
|
|
|
|
function toolPacketLoss () {
|
|
|
|
ping -q -c 10 google.com
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Optimization of SQLite databases of Firefox and Firefox Nightly
|
|
|
|
#
|
|
|
|
function toolOptimizeFirefox () {
|
|
|
|
if (whiptail --title "Firefox SQLite DB Optimization" --yesno "Terminate Firefox and proceed ?" 10 60) then
|
|
|
|
if which firefox >/dev/null; then
|
|
|
|
printf "Optimizing Firefox"
|
|
|
|
pkill -9 firefox
|
|
|
|
for f in ~/.mozilla/firefox/*/*.sqlite; do sqlite3 $f 'VACUUM; REINDEX;'; done
|
|
|
|
printf "\n"
|
|
|
|
fi
|
|
|
|
if which firefox-trunk >/dev/null; then
|
|
|
|
printf "Optimizing Firefox Nightly"
|
|
|
|
pkill -9 firefox-trunk
|
|
|
|
for f in ~/.mozilla/firefox-trunk/*/*.sqlite; do sqlite3 $f 'VACUUM; REINDEX;'; done
|
|
|
|
printf "\n"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# remove useless packages (depedencies)
|
|
|
|
#
|
|
|
|
function toolAutoremove () {
|
|
|
|
runCmd "sudo apt-get -y autoremove" \
|
2018-03-21 07:31:17 +00:00
|
|
|
"Removing not necessary dependencies"
|
2018-03-21 07:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# remove old versions of installed kernels
|
|
|
|
#
|
|
|
|
function toolClearOldKernels () {
|
|
|
|
checkAndInstallDep apt byobu purge-old-kernels
|
|
|
|
runCmd "sudo purge-old-kernels --keep 3" \
|
2018-03-21 07:31:17 +00:00
|
|
|
"Removing old kernels"
|
2018-03-21 07:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# force soundcards detection
|
|
|
|
#
|
|
|
|
function toolSoundCardsDetection () {
|
|
|
|
runCmd "sudo alsa force-reload" \
|
2018-03-21 07:31:17 +00:00
|
|
|
"Detecting ALSA sound cards"
|
2018-03-21 07:26:38 +00:00
|
|
|
}
|