From 7401fd4e548ca7782079eed4af1590dfd859b37a Mon Sep 17 00:00:00 2001 From: Frieder Schlesier Date: Tue, 23 Oct 2018 18:22:03 +0200 Subject: [PATCH] updates --- .aliases | 13 +++++---- .dockerfunc | 15 ++++++++++ .i3/config | 2 +- scripts/install.sh | 71 +++++++++++++++++++++++++++++----------------- 4 files changed, 69 insertions(+), 32 deletions(-) diff --git a/.aliases b/.aliases index 6054f95..e41e191 100755 --- a/.aliases +++ b/.aliases @@ -2,7 +2,8 @@ alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias .....='cd ../../../..' -alias rsync='rsync --progress -v' +alias rs='rsync --progress -v' +alias up='sudo apt update && sudo apt upgrade' alias ll='ls -ahlF' alias la='ls -Ah' @@ -23,9 +24,7 @@ alias libver="ldconfig -p | grep " alias act='sudo systemctl -l -t service --state=active' alias fai='sudo systemctl -l -t service --state=failed' -alias dss='docker stack services ' -alias dsd='docker stack deploy -c docker-compose.yml ' - +# basic docker shortcuts alias dps='docker container ls -a' alias di='docker image ls' alias dv='docker volume ' @@ -33,5 +32,9 @@ alias dvl='docker volume ls' alias dip="docker container inspect -f '{{ .NetworkSettings.IPAddress }}'" # call with or ID alias dih="docker container inspect -f '{{ .Config.Hostname }}'" # call with or ID alias dstats="docker stats "'$(sudo docker ps -aq)' # shows stats thingy for all containers -alias drmsc="docker container ls -a | grep Exited | awk '{print nil}' | xargs docker rm" # removes stopped containers +alias drmsc="docker container ls -a | grep Exited | awk '{print $1}' | xargs docker container rm" # removes stopped containers alias drmdi="docker image remove "'$(docker image ls -q -f dangling=true)' # removes non-tagged images + +# docker swarm +alias dss='docker stack services ' +alias dsd='docker stack deploy -c docker-compose.yml ' diff --git a/.dockerfunc b/.dockerfunc index 2e558f1..b9daf78 100755 --- a/.dockerfunc +++ b/.dockerfunc @@ -71,6 +71,21 @@ android-studio() { #exit 0; } +ansible() { + local args=$@ + local cur_dir=$(pwd) + local targetmount=$(basename $cur_dir) + + docker run -it \ + --name ansible_$targetmount \ + -v ${cur_dir}:/src/$targetmount \ + -w /src/$targetmount \ + -v $HOME/.ssh/:/tmp/.ssh:ro \ + -v /etc/hosts:/etc/hosts:ro \ + ${DOCKER_REPO_PREFIX}/ansible:alpine \ + bash -c "$args" +} + ant() { local args=$@ local cur_dir=$(pwd) diff --git a/.i3/config b/.i3/config index 4ba0094..9a5ae97 100755 --- a/.i3/config +++ b/.i3/config @@ -249,7 +249,7 @@ exec amixer set Master 54 exec --no-startup-id nm-applet exec --no-startup-id xrandr --output LVDS1 --left-of VGA1 --auto exec --no-startup-id xrandr --output VGA1 --auto -exec --no-startup-id clipit +#exec --no-startup-id clipit exec --no-startup-id i3-msg 'workspace $WS1; exec iceweasel;' exec --no-startup-id i3-msg 'workspace $WS2; exec emacs25' exec --no-startup-id i3-msg 'workspace $WS3; exec urxvt;' diff --git a/scripts/install.sh b/scripts/install.sh index ac35adf..996f703 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -5,34 +5,46 @@ set -e # This script installs my basic setup for a debian machine USERNAME=fschl +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 + else + SUDO="" # We're already root + fi +} apt_sources() { - DIST="${$1:-stable}" + # http://deb.debian.org/ + ddist=$1 + DIST="${ddist:-stable}" if [[ ! "stable" -eq ${DIST} ]]; then cat <<-EOF > /etc/apt/sources.list -deb http://ftp.de.debian.org/debian/ ${DIST} main contrib -deb http://ftp.de.debian.org/debian/ ${DIST}-updates main contrib -deb http://security.debian.org/ ${DIST}/updates main +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 http://ftp.de.debian.org/debian/ stable main contrib -deb http://ftp.de.debian.org/debian/ stable-updates main contrib -deb http://security.debian.org/ stable/updates main +deb https://deb.debian.org/debian stable main contrib +deb https://deb.debian.org/debian-security stable-updates main contrib EOF fi - } base_applications() { echo "update and installing baseapps..." - apt update - apt upgrade + $SUDO apt update + $SUDO apt upgrade DEBIAN_FRONTEND=noninteractive - apt install -y \ + $SUDO apt install -y \ apt-transport-https \ automake \ bash-completion \ @@ -47,7 +59,7 @@ base_applications() { git \ gnupg \ gnupg-agent \ - gnupg-curl \ + gnupg \ gnupg2 \ grep \ htop \ @@ -67,10 +79,9 @@ base_applications() { --no-install-recommends echo "... DONE... cleaning up\n\n" - apt autoremove - apt autoclean - apt clean - + $SUDO apt autoremove + $SUDO apt autoclean + $SUDO apt clean } install_server_base() { @@ -113,16 +124,16 @@ EOF no_suspend() { # https://wiki.debian.org/SystemdSuspendSedation - sudo sed -i "s/HandleLidSwitch=.*/HandleLidSwitch=ignore/" /etc/systemd/logind.conf - sudo sed -i "s/HandleLidSwitchDocked=.*/HandleLidSwitchDocked=ignore/" /etc/systemd/logind.conf - sudo sed -i "s/IdleActionSec=.*/IdleActionSec=90min/" /etc/systemd/logind.conf + $SUDO sed -i "s/HandleLidSwitch=.*/HandleLidSwitch=ignore/" /etc/systemd/logind.conf + $SUDO sed -i "s/HandleLidSwitchDocked=.*/HandleLidSwitchDocked=ignore/" /etc/systemd/logind.conf + $SUDO sed -i "s/IdleActionSec=.*/IdleActionSec=90min/" /etc/systemd/logind.conf # turn off screen blanking # https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=18200&sid=135af53eb82496bc64f4c0eefbc86d2c&start=25 # http://raspberrypi.stackexchange.com/questions/752/how-do-i-prevent-the-screen-from-going-blank xset s noblank - sudo systemctl restart systemd-logind.service + $SUDO systemctl restart systemd-logind.service } install_i3() { @@ -180,14 +191,15 @@ install_docker() { echo "installing docker binary Version $VERS ..." # https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount - apt-get install \ + apt install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg2 \ - software-properties-common + software-properties-common \ + --no-install-recommends - curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - + curl -fsSL https://download.docker.com/linux/debian/gpg | $SUDO apt-key add - # add docker apt repo cat <<-EOF > /etc/apt/sources.list.d/docker.list @@ -196,7 +208,16 @@ install_docker() { # deb [arch=amd64] https://download.docker.com/linux/debian stretch nightly EOF + apt update + apt install -y \ + docker-ce \ + --no-install-recommends + groupadd docker + addgroup ${USERNAME} docker + + docker version + docker info } install_compose() { @@ -251,7 +272,7 @@ install_golang() { # subshell because we `cd` ( - curl -sSL "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" | sudo tar -v -C /usr/local -xz + curl -sSL "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" | $SUDO tar -v -C /usr/local -xz ) # get commandline tools @@ -337,8 +358,6 @@ main() { apt_sources base_applications install_docker - sudo groupadd docker - sudo adduser -aG docker "$USERNAME" install_compose ;; dotfiles)