From fd5cc53f7b34b528847d588e035a0e621e89cf0f Mon Sep 17 00:00:00 2001 From: Frieder Schlesier Date: Wed, 2 Jan 2019 12:42:16 +0100 Subject: [PATCH] update install script --- scripts/install.sh | 55 ++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index bc9ba65..7aff8ef 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -10,12 +10,12 @@ SUDO="sudo" check_root() { # We need root rights at some point if [ "$(whoami)" != "root" ]; then - if ! which $SUDO >/dev/null; then - echo "ERROR: $0 is not run as root and $SUDO is not available" >&2 - exit 1 - fi + if ! which $SUDO >/dev/null; then + echo "ERROR: $0 is not run as root and $SUDO is not available" >&2 + exit 1 + fi else - SUDO="" # We're already root + SUDO="" # We're already root fi } @@ -23,17 +23,25 @@ apt_sources() { # http://deb.debian.org/ ddist=$1 DIST="${ddist:-stable}" - if [[ ! "stable" -eq ${DIST} ]]; then - cat <<-EOF > /etc/apt/sources.list -deb https://deb.debian.org/debian ${DIST} main contrib -deb https://deb.debian.org/debian-security ${DIST}/updates main contrib -EOF - else - cat <<-EOF > /etc/apt/sources.list -deb https://deb.debian.org/debian stable main contrib -deb https://deb.debian.org/debian-security stable-updates main contrib -EOF + + allowed_dists=("testing stable stretch buster") + if [ ! ${DIST} in "${allowed_dists[@]}" ]; then + echo "... $DIST was not in allowed dists... setting to stable" + DIST="stable" fi + + echo "writing /etc/apt/sources.list..." + echo "using ${DIST}" + cat <<-EOF > /etc/apt/sources.list +deb http://deb.debian.org/debian ${DIST} main +deb-src http://deb.debian.org/debian ${DIST} main + +deb http://deb.debian.org/debian-security/ ${DIST}/updates main +deb-src http://deb.debian.org/debian-security/ ${DIST}/updates main + +deb http://deb.debian.org/debian ${DIST}-updates main +deb-src http://deb.debian.org/debian ${DIST}-updates main +EOF } base_applications() { @@ -59,8 +67,8 @@ base_applications() { gcc \ git \ gnupg \ - gnupg-agent \ gnupg \ + gnupg-agent \ gnupg2 \ grep \ htop \ @@ -104,13 +112,15 @@ install_server_base() { apt clean echo "setting up logwatch..." + echo "... TODO require email to be set as parameter" + echo "... TODO require email to be set as parameter" cat <<-EOF > /etc/cron.daily/00logwatch /usr/sbin/logwatch --output mail --mailto you@example.com --detail high EOF echo " ... DONE" - # TODO: is this really needed? + # TODO: is this really needed? or default behavior anyway? echo "set unattended upgrades..." cat <<-EOF > /etc/apt/apt.conf.d/10periodic APT::Periodic::Update-Package-Lists "1"; @@ -123,7 +133,6 @@ EOF } - no_suspend() { # https://wiki.debian.org/SystemdSuspendSedation $SUDO sed -i "s/HandleLidSwitch=.*/HandleLidSwitch=ignore/" /etc/systemd/logind.conf @@ -149,15 +158,16 @@ install_nvidia_docker() { sudo apt-get install -y nvidia-docker2 sudo pkill -SIGHUP dockerd } + install_i3() { echo "update and installing i3wm and some tools..." # tlp: Advanced Linux Power Management # http://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html - deb http://repo.linrunner.de/debian sid main + # deb http://repo.linrunner.de/debian sid main # add the tlp apt-repo gpg key - apt-key adv --keyserver pool.sks-keyservers.net --recv-keys CD4E8809 + # apt-key adv --keyserver pool.sks-keyservers.net --recv-keys CD4E8809 DEBIAN_FRONTEND=noninteractive @@ -170,10 +180,12 @@ install_i3() { clipit \ emacs \ feh \ + firefox-esr \ fonts-font-awesome \ fswebcam \ i3 \ i3lock \ + i3lock-fancy \ i3status \ keepassxc \ pulseaudio \ @@ -404,7 +416,7 @@ main() { case "$cmd" in base) - apt_sources + apt_sources stable base_applications install_docker install_compose @@ -417,6 +429,7 @@ main() { ;; desktop) install_i3 + apt_sources buster if [ -f "./get_private_stuff.sh" ]; then source get_private_stuff.sh fi