dotfiles

config files and scripts at HOME.
git clone git://git.ricketyspace.net/dotfiles.git
Log | Files | Refs

commit 2689742b6135b0b7c30f27f6f4bd2d22dac9ba34
parent 190241834de7d2fa89345775134b99fed55fadd6
Author: rsiddharth <s@ricketyspace.net>
Date:   Sun, 30 Apr 2017 05:04:00 +0000

Add .containers/anki

Diffstat:
.containers/anki | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+), 0 deletions(-)

diff --git a/.containers/anki b/.containers/anki @@ -0,0 +1,73 @@ +#!/bin/sh +# +# Copyright © 2017 rsiddharth <s@ricketyspace.net> +# License: GNU General Public License version 3 or higher. +# +# systemd-nspawn container for anki + +PWD=`pwd` +CONTAINER_DIR="boxes" +CONTAINER_NAME="anki" +CONTAINER=$CONTAINER_DIR'/'$CONTAINER_NAME +SCRIPT=`basename "$0"` + +TERMINFO_SRC='/usr/share/terminfo/r/rxvt-256color:' +TERMINFO_BIND=$TERMINFO_SRC'/root/.terminfo/r/rxvt-256color' + +ANKI_DIR='/home/s/anki' + +if [ "$1" = "bootstrap" ]; then + echo 'debootstraping' + mkdir -p $CONTAINER_DIR + sudo debootstrap --arch=amd64 testing $CONTAINER + echo 'starting container' + sudo systemd-nspawn -D ./$CONTAINER \ + --bind-ro=$PWD/$SCRIPT:/root/$SCRIPT \ + /root/$SCRIPT install +elif [ "$1" = "install" ]; then + echo 'installing paraphernalia in container' + apt-get update -y + apt-get install -y git python3-pip python3-pyqt5 \ + python3-pyqt5.qtwebengine pyqt5-dev-tools \ + portaudio19-dev mplayer lame sudo + id -u s &>/dev/null || adduser --disabled-login --gecos "" s + cd $ANKI_DIR || git clone git://github.com/dae/anki.git $ANKI_DIR \ + cd $ANKI_DIR + pip3 install -r requirements.txt + ./tools/build_ui.sh + chown -R s:s $ANKI_DIR +elif [ "$1" = "start-container" ]; then + echo 'starting container' + xhost +local: + sudo systemd-nspawn --setenv=DISPLAY=:0.0 \ + -D ./$CONTAINER \ + --setenv=XAUTHORITY=~/.Xauthority \ + --bind=/tmp/ \ + --bind=/home/s/.Xauthority:/root/.Xauthority \ + --bind-ro=$PWD/$SCRIPT:/root/$SCRIPT \ + --bind-ro=$TERMINFO_BIND +elif [ "$1" = "start-anki" ]; then + echo 'starting anki in container' + xhost +local: + sudo systemd-nspawn --setenv=DISPLAY=:0.0 \ + -D ./$CONTAINER \ + --setenv=XAUTHORITY=~/.Xauthority \ + --bind=/tmp/ \ + --bind=/home/s/.Xauthority:/root/.Xauthority \ + --bind-ro=$PWD/$SCRIPT:/root/$SCRIPT \ + /root/$SCRIPT run-anki + annex-anki +elif [ "$1" = "run-anki" ]; then + echo 'updating container' + apt-get update -y + apt-get upgrade -y + echo 'starting anki...' + cd $ANKI_DIR + git pull + ./tools/build_ui.sh + sudo -H -u s ./runanki + cp -f /home/s/collection.apkg /tmp/ +else + echo 'Dunno what to do' + exit 1 +fi