Last active
July 14, 2016 06:24
-
-
Save JeffreyVdb/eede8af0cd4bf2f3400b to your computer and use it in GitHub Desktop.
PostInstall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Ubuntu 14.04 Gnome edition post install script | |
ADD_REPO="add-apt-repository -y" | |
RM="rm -f" | |
MKDIR="mkdir -p" | |
BITMAPPED_FONTS=1 | |
LIQUORIX_KERNEL=1 | |
NVIDIA_CLOSED_SOURCE=1 | |
NVIDIA_VERSION=331 | |
KEEPASS=1 | |
BITTORRENT_SYNC=1 | |
SOURCES_BASE="/etc/apt/sources.list.d" | |
SCRIPT_REQUIREMENTS=(curl) | |
PACKAGES=(sysv-rc-conf git-core terminator xfonts-terminus vim gksu) | |
THEMEDIR="/usr/share/themes" | |
ICONDIR="/usr/share/icons" | |
GTK_THEME="http://gnome-look.org/CONTENT/content-files/154296-FlatStudio-1.03.tar.gz" | |
# SSD | |
TUNE_SSDS=1 | |
SSD_SCHEDULER="deadline" | |
pkg_upgrade() { | |
apt-get upgrade -y --force-yes | |
} | |
pkg_update() { | |
apt-get update -q $* | |
} | |
pkg_install() { | |
apt-get -y --force-yes install $* | |
} | |
to_sources_list() { | |
local teecmd="tee" | |
local fName="${SOURCES_BASE}/${1}.list" | |
if [ -e $fName ]; then | |
teecmd="$teecmd -a" | |
fi | |
echo "$2" | $teecmd $fName | |
} | |
ssd_optimize() { | |
local OPTIMIZE_SCRIPT="/usr/local/bin/optimize_ssd.sh" | |
# check if there are any ssds on the system | |
local ssd_udev_file="/etc/udev/rules.d/60-io_schedulers.rules" | |
local blocks=$(ls -d /sys/block/sd?) | |
local found_ssd=0 | |
for b in $blocks; do | |
rotating=$(cat $b/queue/rotational) | |
sched="$b/queue/scheduler" | |
if [[ $rotating -eq 0 ]] && [[ -w "$sched" ]]; then | |
# set to requested scheduler | |
echo "ssd found {$b}, setting scheduler to $SSD_SCHEDULER" | |
echo $SSD_SCHEDULER > $sched | |
# found ssd, set variable | |
found_ssd=1 | |
fi | |
done | |
# if ssd is found, install udev file | |
[ $found_ssd -eq 1 ] && install_ssd_udev_rule $ssd_udev_file | |
} | |
install_ssd_udev_rule() { | |
echo "install udev file for ssd optimization" | |
cat <<EOF | tee "$1" >/dev/null 2>&1 | |
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="$SSD_SCHEDULER" | |
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="cfq" | |
EOF | |
} | |
if ! test $EUID -eq 0; then | |
echo 'not root' | |
exit 1 | |
fi | |
# add repositories | |
$ADD_REPO "ppa:nitrux/nitrux-artwork" | |
# Upgrade all packages first | |
pkg_update | |
pkg_upgrade | |
# Install software | |
pkg_install ${PACKAGES[*]} ${SCRIPT_REQUIREMENTS[*]} | |
# Enable bitmapped fonts | |
if [ $BITMAPPED_FONTS -eq 1 ]; then | |
cd /etc/fonts/conf.d | |
rm -f 70-no-bitmaps.conf | |
ln -s ../conf.avail/70-yes-bitmaps.conf . | |
# Refresh font cache | |
fc-cache -fv | |
fi | |
# Liquorix kernel | |
if [ $LIQUORIX_KERNEL -eq 1 ]; then | |
$RM "${SOURCES_BASE}/liquorix.list" | |
to_sources_list "liquorix" "deb http://liquorix.net/debian sid main" | |
to_sources_list "liquorix" "deb-src http://liquorix.net/debian sid main" | |
# install it | |
pkg_update | |
pkg_install '^liquorix-([^-]+-)?keyring.?' | |
# update to reflect changes | |
pkg_update | |
# install kernel | |
pkg_install linux-headers-liquorix-amd64 linux-image-liquorix-amd64 | |
fi | |
# Nvidia closed source driver | |
if [ $NVIDIA_CLOSED_SOURCE -eq 1 ]; then | |
$ADD_REPO "ppa:xorg-edgers/ppa" | |
pkg_update | |
# Install nvidia driver | |
pkg_install nvidia-${NVIDIA_VERSION} | |
# upgrade distro packages | |
pkg_upgrade | |
# Create xorg.conf | |
nvidia-xconfig | |
fi | |
# Install keepassx | |
if [ $KEEPASS -eq 1 ] && ! which keepassx &>/dev/null; then | |
pkg_install libxtst-dev cmake libgcrypt11-dev libqt4-dev build-essential zlib1g-dev | |
cd /tmp | |
git clone "https://github.com/keepassx/keepassx.git" | |
cd keepassx | |
$MKDIR build && cd build | |
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local | |
make 2>&1 | tee make.log | |
make install 2>&1 | tee make-install.log | |
# bug, applications not read from /usr/local/share/applications - weird | |
# /usr/local/share/applications -> /usr/share/applications | |
mv /usr/{local/,}share/applications/keepassx.desktop | |
fi | |
# Install Bittorrent Sync | |
if [ $BITTORRENT_SYNC -eq 1 ] && ! which btsync &>/dev/null; then | |
cd /tmp | |
wget -O - "http://download-lb.utorrent.com/endpoint/btsync/os/linux-x64/track/stable" \ | |
| tar -xzf - | |
install -m 0755 btsync "/usr/local/bin" | |
fi | |
# optimize ssd | |
test $TUNE_SSDS -eq 1 && ssd_optimize | |
# theme and icon folders | |
if [ -n "$GTK_THEME" ]; then | |
# download theme and extract in theme directory | |
curl "$GTK_THEME" | tar -xzf - -C $THEMEDIR | |
fi | |
# Nitrux icon theme | |
pkg_install nitrux-icon-theme | |
# cleanup | |
apt-get autoclean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment