From 020a96cf66595d47eba58724d28aeb3e88c907cf Mon Sep 17 00:00:00 2001 From: Karel Kočí Date: Fri, 7 Apr 2017 14:43:23 +0200 Subject: Add gtk and qt theme configuration --- install | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'install') diff --git a/install b/install index a520b42..46a5d3c 100755 --- a/install +++ b/install @@ -91,6 +91,13 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then inst local/bin/sys-suspend ~/.local/bin/ fi +read -p "Install Gtk+ and Qt theme setup? (Y/n) " +if [[ $REPLY =~ ^[Yy]?$ ]]; then + inst gtk-2.0/gtkrc ~/.gtkrc-2.0 + inst gtk-3.0/ ~/.config/gtk-3.0/ + inst config/Trolltech.conf ~/.config/Trolltech.conf +fi + read -p "Install Conkeror configuration? (Y/n) " if [[ $REPLY =~ ^[Yy]?$ ]]; then inst conkerorrc ~/.conkerorrc -- cgit v1.3 From 8d39ed9e2804c6c9ed42aa685f6eb2f7c38fbbea Mon Sep 17 00:00:00 2001 From: Karel Kočí Date: Sat, 8 Apr 2017 21:53:52 +0200 Subject: Fix syncemail (option -s is gone) --- install | 1 + local/sbin/syncemail | 10 +++++++--- private | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'install') diff --git a/install b/install index 46a5d3c..5616075 100755 --- a/install +++ b/install @@ -59,6 +59,7 @@ fi read -p "Install email synchronization? (Y/n) " if [[ $REPLY =~ ^[Yy]?$ ]]; then inst local/bin/email-unread ~/.local/bin/email-unread + inst local/sbin/newmail-notify ~/.local/sbin/newmail-notify inst_email_sync # Contains: # inst local/sbin/syncemail ~/.local/sbin/ diff --git a/local/sbin/syncemail b/local/sbin/syncemail index dfd56a3..3cb56a4 100755 --- a/local/sbin/syncemail +++ b/local/sbin/syncemail @@ -5,6 +5,7 @@ import sys import subprocess import daemon import lockfile +import syslog from offlineimap import OfflineImap pidfile = '/tmp/syncemail-%d.pid' % os.getuid() @@ -33,12 +34,15 @@ for acc in accounts: sys.argv.append('-k') sys.argv.append('Repository_' + acc[0] + '-remote:remotepass=' + output) -sys.argv.append('-s') # output to syslog -sys.argv.append('-u') -sys.argv.append('syslog') +# Define out logger and redirect stdout and stderr to it +class logstd: + def write(self, data): + syslog.syslog(data) with daemon.DaemonContext(): check_running() with open(pidfile, "w") as f: f.write("%s" % os.getpid()) + syslog.openlog('syncemail') + sys.stderr = sys.stdout = logstd() OfflineImap().run() diff --git a/private b/private index 3f5aa66..3b11f0b 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit 3f5aa66bb2c6b888958356385bcb23813b5ec15a +Subproject commit 3b11f0bb0bce7f594ee4ba1dddc1aea8bdeb5cc5 -- cgit v1.3 From 3b15d8dcd8912825281367ed959d7ad212e6a0ab Mon Sep 17 00:00:00 2001 From: Karel Kočí Date: Sat, 8 Apr 2017 21:56:30 +0200 Subject: Add user services --- install | 6 ++++ local/sbin/user-service.sh | 90 ++++++++++++++++++++++++++++++++++++++++++++++ profile | 5 ++- service/mpd | 23 ++++++++++++ service/syncthing | 19 ++++++++++ 5 files changed, 142 insertions(+), 1 deletion(-) create mode 100755 local/sbin/user-service.sh create mode 100755 service/mpd create mode 100755 service/syncthing (limited to 'install') diff --git a/install b/install index 5616075..fd4a9f0 100755 --- a/install +++ b/install @@ -30,6 +30,12 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then inst local/git-prompt.sh ~/.local/ fi +read -p "Install user services? (Y/n) " +if [[ $REPLY =~ ^[Yy]?$ ]]; then + inst local/sbin/user-service.sh ~/.local/sbin/user-service.sh + inst service/ ~/.service/ +fi + read -p "Install VIM scripts? (Y/n) " YCM_PATH=~/.vim/bundle/YouCompleteMe if [[ $REPLY =~ ^[Yy]?$ ]]; then diff --git a/local/sbin/user-service.sh b/local/sbin/user-service.sh new file mode 100755 index 0000000..e48bb9d --- /dev/null +++ b/local/sbin/user-service.sh @@ -0,0 +1,90 @@ +#!/bin/sh +set -e + +[ -z "$1" ] && {echo "Run this script only from user-service file!" && exit 1} + +# Name of service +NAME="$(basename "$1")" +SERVICE="$1" + +# Source input file +. "$1" +shift + +OP="status" +Q=true +# Parse arguments +while [ -n "$1" ]; do + case "$1" in + -h|--help) + echo "User service: $NAME" + echo " $description" + echo "$SERVICE [OPTION]... OPERATION" + echo " Options:" + echo " -q - be quiet" + echo " Operations:" + echo " status - show status of service" + echo " start - start service" + echo " stop - stop service" + echo " restart - restart service" + ;; + -q) + Q=false + ;; + status|start|stop|restart) + OP="$1" + ;; + *) + echo "Unknown argument: $1" + exit 1 + ;; + esac + shift +done + +case "$OP" in + status) + if status; then + $Q && echo "Service $NAME is running" + exit 0 + else + $Q && echo "Service $NAME is not running" + exit 1 + fi + ;; + start) + $Q && echo -n "Starting service $NAME..." + if start; then + $Q && echo " ok" + else + $Q && echo " fail" + exit 1 + fi + ;; + stop) + $Q && echo -n "Stopping service $NAME..." + if stop; then + $Q && echo " ok" + else + $Q && echo " fail" + exit 1 + fi + ;; + restart) + $Q && echo "Restarting service $NAME..." + if ! stop; then + $Q && echo " stop failed" + exit 1 + fi + if start; then + $Q && echo " ok" + else + $Q && echo " start failed" + exit 1 + fi + ;; + *) + echo "Invalid operation!" + exit 3 + ;; +esac diff --git a/profile b/profile index ee3522c..cbee52d 100644 --- a/profile +++ b/profile @@ -2,8 +2,11 @@ [[ "$(tty)" != /dev/tty* ]] && return # Start music player daemon -mpd ~/.config/mpd/mpd.conf +~/.service/mpd -q status || ~/.service/mpd start # Start email synchronization ~/.local/sbin/syncemail +# Start syncthing +~/.service/syncthing -q status || ~/.service/syncthing start + # And if we are on first terminal also automatically start x server [ "$(tty)" = "/dev/tty1" ] && exec startx -- vt1 diff --git a/service/mpd b/service/mpd new file mode 100755 index 0000000..4f0f467 --- /dev/null +++ b/service/mpd @@ -0,0 +1,23 @@ +#!/home/cynerd/.local/sbin/user-service.sh +# vim: ft=sh + +description="Music player daemon" +pidfile=".config/mpd/pid" + +MPD_PID=~/.config/mpd/pid +if [ ! -e $MPD_PID ] || ! kill -0 $(cat $MPD_PID); then + mpd ~/.config/mpd/mpd.conf +fi + +status() { + [ -f $pidfile ] || return 1 + kill -0 "$(cat $pidfile)" || return 1 +} + +start() { + mpd ~/.config/mpd/mpd.conf +} + +stop() { + mpd --kill ~/.config/mpd/mpd.conf +} diff --git a/service/syncthing b/service/syncthing new file mode 100755 index 0000000..8d0e009 --- /dev/null +++ b/service/syncthing @@ -0,0 +1,19 @@ +#!/home/cynerd/.local/sbin/user-service.sh +# vim: ft=sh + +description="Syncthing is an open, trustworthy and decentralized cloud storage system" +pidfile="/tmp/syncthing-$USER.pid" +logfile="/var/log/syncthing-$USER.log" + +status() { + [ -f $pidfile ] || return 1 + kill -0 "$(cat $pidfile)" || return 1 +} + +start() { + start-stop-daemon -S -bmp $pidfile -1 $logfile -2 $logfile -- syncthing -no-browser +} + +stop() { + start-stop-daemon -K -p $pidfile -x syncthing +} -- cgit v1.3 From 968eb80c3fa1d3581186e47ff8d3c7a32aa6b577 Mon Sep 17 00:00:00 2001 From: Karel Kočí Date: Mon, 10 Apr 2017 12:39:43 +0200 Subject: Add screenrc --- install | 5 +++++ screenrc | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 screenrc (limited to 'install') diff --git a/install b/install index fd4a9f0..15b8994 100755 --- a/install +++ b/install @@ -30,6 +30,11 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then inst local/git-prompt.sh ~/.local/ fi +read -p "Install configurations for various utility tools? (Y/n) " +if [[ $REPLY =~ ^[Yy]?$ ]]; then + inst screenrc ~/.screenrc +fi + read -p "Install user services? (Y/n) " if [[ $REPLY =~ ^[Yy]?$ ]]; then inst local/sbin/user-service.sh ~/.local/sbin/user-service.sh diff --git a/screenrc b/screenrc new file mode 100644 index 0000000..e456d12 --- /dev/null +++ b/screenrc @@ -0,0 +1,3 @@ +defscrollback 50000 +termcapinfo xterm* ti@:te@ +termcapinfo rxvt* ti@:te@ -- cgit v1.3 From 010a14c4d12af624c00d257d27d53a14abd2b7e1 Mon Sep 17 00:00:00 2001 From: Karel Kočí Date: Fri, 28 Apr 2017 14:52:18 +0200 Subject: Add xshot and clip X utility scripts --- install | 8 ++++---- local/bin/clip | 2 ++ local/bin/xshot | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100755 local/bin/clip create mode 100755 local/bin/xshot (limited to 'install') diff --git a/install b/install index 15b8994..66d4251 100755 --- a/install +++ b/install @@ -101,10 +101,10 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then inst local/bin/sys-reboot ~/.local/bin/ inst local/bin/sys-shutdown ~/.local/bin/ inst local/bin/sys-suspend ~/.local/bin/ -fi - -read -p "Install Gtk+ and Qt theme setup? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then + # Some small Xserver tools + inst local/bin/clip ~/.local/bin/ + inst local/bin/xshot ~/.local/bin/ + # Theme inst gtk-2.0/gtkrc ~/.gtkrc-2.0 inst gtk-3.0/ ~/.config/gtk-3.0/ inst config/Trolltech.conf ~/.config/Trolltech.conf diff --git a/local/bin/clip b/local/bin/clip new file mode 100755 index 0000000..1281090 --- /dev/null +++ b/local/bin/clip @@ -0,0 +1,2 @@ +#!/bin/sh +xclip -selection clipboard diff --git a/local/bin/xshot b/local/bin/xshot new file mode 100755 index 0000000..90f91af --- /dev/null +++ b/local/bin/xshot @@ -0,0 +1,2 @@ +#!/bin/sh +import -window "$(xdotool selectwindow)" ~/xshot_$(date +%F_%H%M%S_%N).png -- cgit v1.3 From a2470a03197893500545e0b33892414ace204c36 Mon Sep 17 00:00:00 2001 From: Karel Kočí Date: Wed, 3 May 2017 10:57:23 +0200 Subject: Add colors to printed messages --- install | 42 ++++++++++++++---------------------------- utils/inst | 22 ++++++++++++++-------- 2 files changed, 28 insertions(+), 36 deletions(-) (limited to 'install') diff --git a/install b/install index 66d4251..8b33e60 100755 --- a/install +++ b/install @@ -10,40 +10,34 @@ git submodule update --init || (echo "Submodule update failed!"; exit 5) ################################################################################# source private/install # private files, sorry but some privacy is required. -read -p "Install Bashrc? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install Bashrc?"; then inst bashrc ~/.bashrc inst shellrc ~/.shellrc inst profile ~/.profile fi -read -p "Install zshrc? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install zshrc?"; then inst zshrc ~/.zshrc inst shellrc ~/.shellrc inst zprofile ~/.zprofile fi -read -p "Install GIT configuration? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install GIT configuration?"; then inst gitconfig ~/.gitconfig inst local/git-prompt.sh ~/.local/ fi -read -p "Install configurations for various utility tools? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install configurations for various utility tools?"; then inst screenrc ~/.screenrc fi -read -p "Install user services? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install user services?"; then inst local/sbin/user-service.sh ~/.local/sbin/user-service.sh inst service/ ~/.service/ fi -read -p "Install VIM scripts? (Y/n) " YCM_PATH=~/.vim/bundle/YouCompleteMe -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install VIM scripts?"; then # See if we have anything different from what we have in repository YCM_REV="$(cd $YCM_PATH && git --work-tree=. diff --exit-code -s && echo y)" inst vimrc ~/.vimrc @@ -59,16 +53,14 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then fi fi -read -p "Install ranger configuration? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install ranger configuration?"; then mkdir -p ~/.config/ranger inst config/ranger/rc.conf ~/.config/ranger/rc.conf inst config/ranger/rifle.conf ~/.config/ranger/rifle.conf inst config/ranger/scope.sh ~/.config/ranger/scope.sh fi -read -p "Install email synchronization? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install email synchronization?"; then inst local/bin/email-unread ~/.local/bin/email-unread inst local/sbin/newmail-notify ~/.local/sbin/newmail-notify inst_email_sync @@ -77,8 +69,7 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then # inst config/offlineimap/ ~/.config/offlineimap fi -read -p "Install mutt configuration? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install mutt configuration?"; then inst urlview ~/.urlview inst mutt/mailcap ~/.mutt/ inst mutt/gpg.rc ~/.mutt/ @@ -90,8 +81,7 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then mkdir -p ~/.cache/mutt # directory for temporaly html files fi -read -p "Install i3 configuration and related tools? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install i3 configuration and related tools?"; then inst xinitrc ~/.xinitrc inst Xresources ~/.Xresources inst config/i3/ ~/.config/i3 @@ -110,23 +100,19 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then inst config/Trolltech.conf ~/.config/Trolltech.conf fi -read -p "Install Conkeror configuration? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install Conkeror configuration?"; then inst conkerorrc ~/.conkerorrc inst conkeror/ ~/.conkeror fi -read -p "Install MPD configuration? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install MPD configuration?"; then inst config/mpd/ ~/.config/mpd fi -read -p "Install backup script? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install backup script?"; then inst local/bin/system-backup ~/.local/bin/system-backup fi -read -p "Install lxc-net script? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then +if ask "Install lxc-net script?"; then inst local/bin/lxc-net ~/.local/bin/lxc-net fi diff --git a/utils/inst b/utils/inst index b9da163..7fd648f 100644 --- a/utils/inst +++ b/utils/inst @@ -1,6 +1,12 @@ # Functions used for interactive installation of new changes to running system # vim: ft=sh +ask() { + echo -ne "\e[1;34m$1 (Y/n) \e[0m" + read + return [[ $REPLY =~ ^[Yy]?$ ]] +} + dodiff() { if [ -d "$2" ]; then # If we just copying some file to directory @@ -9,7 +15,7 @@ dodiff() { OUT=$2 fi if ! [ -f "$OUT" ]; then - echo "Not installed: $1 => $OUT" + echo -e "\e[1;33mNot installed:\e[0m $1 => $OUT" read -p "Install? (Y/n) " if [[ $REPLY =~ ^[Yy]?$ ]]; then doinst "$1" "$OUT" @@ -17,7 +23,7 @@ dodiff() { return fi if cmp "$1" "$OUT" >/dev/null; then - echo "No difference detected: $OUT" + echo -e "\e[1;32mNo difference detected:\e[0m $OUT" return fi vimdiff "$1" "$OUT" @@ -31,7 +37,7 @@ checkdiff() { # directory than it have to have trailing slash to ensure that no # additional directory is created. if ! echo "$1" | grep -qE '/$'; then - echo ERROR: Directory without trailing slash detected: $1 + echo -e "\e[1;31mERROR: Directory without trailing slash detected:\e[0m $1" exit 1 fi # Got trough all files ignoring git repositories @@ -43,7 +49,7 @@ checkdiff() { for d in `find "$1" -type d -print -exec test -e '{}'/.git \; -prune`; do D="${d#$1}" if [ ! -d "$2/$D" ]; then - echo "Directory not installed: $1/$D => $2/$D" + echo -e "\e[1;33mDirectory not installed:\e[0m $1/$D => $2/$D" read -p "Install? (Y/n) " if [[ $REPLY =~ ^[Yy]?$ ]]; then doinst "$1/$D/" "$2/$D" @@ -57,9 +63,9 @@ checkdiff() { cd "$2/$G" # Check if we have any change at all if git --work-tree=. diff --exit-code -s; then - echo "No difference detected in git: $2/$G" + echo -e "\e[1;32mNo difference detected in git:\e[0m $2/$G" else - echo "Checkout of git repository: $2/$G" + echo -e "\e[0;32mCheckout of git repository:\e[0m $2/$G" # Checkout all files to HEAD git --work-tree=. checkout -f HEAD # Update all submodules @@ -77,14 +83,14 @@ checkdiff() { # commands not on deployed tree but on tree in this repository, so we need specify # work tree on command line every time we want target deployed work tree. doinst() { - echo rsync -rlpt $1 $2 + echo -e "\e[1;34mrsync -rlpt $1 $2\e[0m" rsync -rlpt $1 $2 # Now edit all .git files in target directory for g in `find "$2" -name '.git' -type f`; do if ! grep -q "gitdir: " "$g"; then continue # Probably not a git repository or who knows. fi - echo "Pointing git repository $g to this repository" + echo -e "\e[1;34mPointing git repository $g to this repository\e[0m" echo gitdir: $PWD/.git`sed "s/^gitdir: [./]*git//" "$g"` > "$g" done } -- cgit v1.3 From 98305e117e89073e5debca2db60d4cb12b6ad7d0 Mon Sep 17 00:00:00 2001 From: Karel Kočí Date: Wed, 3 May 2017 16:33:03 +0200 Subject: Install user-dirs.dirs --- install | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'install') diff --git a/install b/install index 8b33e60..873d3d0 100755 --- a/install +++ b/install @@ -81,7 +81,7 @@ if ask "Install mutt configuration?"; then mkdir -p ~/.cache/mutt # directory for temporaly html files fi -if ask "Install i3 configuration and related tools?"; then +if ask "Install desktop (i3..)?"; then inst xinitrc ~/.xinitrc inst Xresources ~/.Xresources inst config/i3/ ~/.config/i3 @@ -98,6 +98,8 @@ if ask "Install i3 configuration and related tools?"; then inst gtk-2.0/gtkrc ~/.gtkrc-2.0 inst gtk-3.0/ ~/.config/gtk-3.0/ inst config/Trolltech.conf ~/.config/Trolltech.conf + # User directories + inst config/user-dirs.dirs ~/.config/user-dirs.dirs fi if ask "Install Conkeror configuration?"; then -- cgit v1.3