aboutsummaryrefslogtreecommitdiff
path: root/local
diff options
context:
space:
mode:
Diffstat (limited to 'local')
-rwxr-xr-xlocal/bin/asus-fan28
-rwxr-xr-xlocal/bin/clip2
-rwxr-xr-xlocal/bin/email-unread33
-rwxr-xr-xlocal/bin/lxc-net41
-rwxr-xr-xlocal/bin/mxrandr119
-rwxr-xr-xlocal/bin/steam10
-rwxr-xr-xlocal/bin/sys-reboot2
-rwxr-xr-xlocal/bin/sys-shutdown2
-rwxr-xr-xlocal/bin/sys-suspend2
-rwxr-xr-xlocal/bin/system-backup75
-rwxr-xr-xlocal/bin/vim-project-gen4
-rwxr-xr-xlocal/bin/xshot2
-rwxr-xr-xlocal/sbin/newmail-notify23
-rwxr-xr-xlocal/sbin/syncemail48
-rwxr-xr-xlocal/sbin/user-service.sh90
15 files changed, 0 insertions, 481 deletions
diff --git a/local/bin/asus-fan b/local/bin/asus-fan
deleted file mode 100755
index 09e54f1..0000000
--- a/local/bin/asus-fan
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-# TODO this probably should be auto detected, because hwmon number can change
-HWMON=/sys/devices/platform/asus-nb-wmi/hwmon/hwmon1
-
-if [ "$(whoami)" != "root" ]; then
- echo "Run $0 only with root privileges"
- exit -1
-fi
-
-case "$1" in
- -h|--help)
- echo "Usage: $0 -h|full|auto"
- echo "This script controls asus hwmon"
- echo " full - Full throttle"
- echo " auto - Automatic hardware control"
- ;;
- full)
- echo 1 > $HWMON/pwm1_enable
- echo 255 > $HWMON/pwm1
- ;;
- auto)
- echo 0 > $HWMON/pwm1_enable
- ;;
- *)
- echo "Unknown or no option given!"
- exit -2
- ;;
-esac
diff --git a/local/bin/clip b/local/bin/clip
deleted file mode 100755
index 1281090..0000000
--- a/local/bin/clip
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-xclip -selection clipboard
diff --git a/local/bin/email-unread b/local/bin/email-unread
deleted file mode 100755
index dec7d04..0000000
--- a/local/bin/email-unread
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-use File::Find;
-
-use constant EMAIL => glob("~/.mail");
-my $IGNORE = "(Spam|trash|Important)";
-
-my $V = (shift || "") eq "-s";
-
-opendir(EDIR, EMAIL) or die $!;
-while (readdir EDIR) {
- next if /^\./ or not (-d EMAIL."/$_");
- our $count = 0;
-
- sub new_dir {
- my $path = substr $File::Find::name, 1 + length EMAIL;
- $path =~ s/\/new$//;
- return if $_ ne "new" or $path =~ /$IGNORE/;
- my $cnt = 0;
- opendir(NDIR, "$File::Find::name") or die $!;
- while (readdir NDIR) {
- $cnt += 1 unless /^\./;
- }
- closedir(NDIR);
- print "$path: $cnt\n" if not $V and $cnt > 0;
- $count += $cnt;
- }
- find(\&new_dir, EMAIL."/$_");
-
- print "$_: $count\n" if $V and $count > 0;
-}
-closedir(EDIR);
diff --git a/local/bin/lxc-net b/local/bin/lxc-net
deleted file mode 100755
index 53ccb50..0000000
--- a/local/bin/lxc-net
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-
-if [ "$(id -u)" -ne 0 ]; then
- echo "Root required for execution" >&2
- exit 1
-fi
-
-# What if we want to clean
-if [ "$1" = "clean" ]; then
- kill $(cat /tmp/lxc-dhcpd.pid)
- rm -f /tmp/lxc-dhcpd.pid /tmp/lxc-dhcpd.conf
- ip link del dev vbr0
- exit
-fi
-
-# Setup bridge
-ip link add name vbr0 type bridge
-ip link set vbr0 up
-ip addr add 192.168.30.1/24 dev vbr0
-
-# Start dhcp server
-
-# This just takes first dns nameserver configured. Maybe we might want to be
-# little bit more clever.
-DNS_SERVER=$(cat /etc/resolv.conf |grep -i nameserver|head -n1|cut -d ' ' -f2)
-echo "# DHCPD configuration generated by lxc-net script
-authoritative;
-default-lease-time 600;
-max-lease-time 7200;
-option subnet-mask 255.255.255.0;
-option broadcast-address 192.168.30.255;
-option routers 192.168.30.1;
-option domain-name-servers $DNS_SERVER;
-subnet 192.168.30.0 netmask 255.255.255.0 {
- range 192.168.30.10 192.168.30.100;
-}" > /tmp/lxc-dhcpd.conf
-dhcpd -4 -pf /tmp/lxc-dhcpd.pid -cf /tmp/lxc-dhcpd.conf vbr0
-
-# Setup network forwarding (TODO add -o ethX to iptable command)
-sysctl -w net.ipv4.ip_forward=1
-iptables -t nat -A POSTROUTING -j MASQUERADE
diff --git a/local/bin/mxrandr b/local/bin/mxrandr
deleted file mode 100755
index 7c51128..0000000
--- a/local/bin/mxrandr
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/bin/bash
-
-# get info from xrandr
-connectedOutputs=$(xrandr | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")
-activeOutput=$(xrandr | grep -E " connected (primary )?[1-9]+" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")
-disconnectedOutputs=$(xrandr | grep -E " disconnected (primary )?[1-9]+" | awk '{print $1}')
-
-cmd="xrandr "
-cmd_def=$cmd
-
-INTERNAL=eDP1
-HDMI=HDMI1
-VGA=VGA1
-
-for device in "$disconnectedOutputs"; do
- if [ -n "$defice" ]; then
- if [[ "$activeOutput" == *"$device"* ]]; then
- cmd=$cmd" --output $device --off"
- fi
- fi
-done
-
-function only_internal {
- cmd=$cmd" --output $INTERNAL --auto --primary"
- cmd=$cmd" --output $HDMI --off"
- cmd=$cmd" --output $VGA --off"
-}
-
-function internal_vga {
- cmd=$cmd" --output $INTERNAL --auto --primary"
- cmd=$cmd" --output $HDMI --off"
- cmd=$cmd" --output $VGA --auto --right-of $INTERNAL"
-}
-
-function internal_hdmi {
- cmd=$cmd" --output $INTERNAL --auto --right-of $HDMI"
- cmd=$cmd" --output $HDMI --auto --primary"
- cmd=$cmd" --output $VGA --off"
-}
-
-function internal_hdmi_vga {
- cmd=$cmd" --output $INTERNAL --auto --right-of $HDMI"
- cmd=$cmd" --output $HDMI --auto --primary"
- cmd=$cmd" --output $VGA --auto --left-of $HDMI"
-}
-
-function cmd_exec {
- if [ "$cmd" != "$cmd_def" ]; then
- echo $cmd
- `$cmd`
- fi
-}
-
-
-if [ $# -le 1 ]; then
- if [[ "$connectedOutputs" == *"$HDMI"* ]]; then
- if [[ "$connectedOutputs" == *"$VGA"* ]]; then
- internal_hdmi_vga
- else
- internal_hdmi
- fi
- else
- if [[ "$connectedOutputs" == *"$VGA"* ]]; then
- internal_vga
- else
- only_internal
- fi
- fi
- cmd_exec
- exit
-fi
-
-if [ "$2" != "mode" ]; then
- if [[ "$connectedOutputs" != *"$2"* ]]; then
- echo No $2 display known
- exit
- fi
-fi
-
-case "$1" in
- toggle)
- case "$2" in
- $INTERNAL)
- if [[ "$activeOutput" == *"$INTERNAL"* ]]; then
- cmd=$cmd" --output $INTERNAL --off"
- else
- if [[ "$activeOutput" == *"$HDMI"* ]]; then
- cmd=$cmd" --output $INTERNAL --auto --right-of $HDMI"
- else
- cmd=$cmd" --output $INTERNAL --auto --primary"
- fi
- fi
- ;;
- $HDMI)
- if [[ "$activeOutput" == *"$HDMI"* ]]; then
- cmd=$cmd" --output $HDMI --off"
- else
- if [[ "$activeOutput" == *"$VGA"* ]]; then
- cmd=$cmd" --output $HDMI --auto --primary"
- else
- cmd=$cmd" --output $HDMI --auto --right-of $INTERNAL"
- fi
- fi
- ;;
- $VGA)
- if [[ "$activeOutput" == *"$VGA"* ]]; then
- cmd=$cmd" --output $VGA --off"
- else
- if [[ "$activeOutput" == *"$HDMI"* ]]; then
- cmd=$cmd" --output $VGA --auto --left-of $HDMI"
- else
- cmd=$cmd" --output $VGA --auto --right-of $INTERNAL"
- fi
- fi
- ;;
- esac
- ;;
-esac
-cmd_exec
diff --git a/local/bin/steam b/local/bin/steam
deleted file mode 100755
index b573daf..0000000
--- a/local/bin/steam
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-#export STEAM_RUNTIME=0
-export STEAM_RUNTIME_PREFER_HOST_LIBRARIES=0
-# Workaround for dbus fatal termination related coredumps (SIGABRT)
-# https://github.com/ValveSoftware/steam-for-linux/issues/4464
-export DBUS_FATAL_WARNINGS=0
-# Override some libraries as these are what games linked against.
-export LD_LIBRARY_PATH="/usr/lib/steam:/usr/lib32/steam"
-#export LD_PRELOAD="/usr/lib/steam:/usr/lib32/steam /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/libstdc++.so.6 /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/libgcc_s.so.1 /usr/lib64/libxcb.so.1 /usr/lib64/libgpg-error.so"
-exec /usr/bin/steam "$@"
diff --git a/local/bin/sys-reboot b/local/bin/sys-reboot
deleted file mode 100755
index 24a024c..0000000
--- a/local/bin/sys-reboot
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
diff --git a/local/bin/sys-shutdown b/local/bin/sys-shutdown
deleted file mode 100755
index bff9762..0000000
--- a/local/bin/sys-shutdown
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
diff --git a/local/bin/sys-suspend b/local/bin/sys-suspend
deleted file mode 100755
index 49b4b2e..0000000
--- a/local/bin/sys-suspend
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Suspend boolean:true
diff --git a/local/bin/system-backup b/local/bin/system-backup
deleted file mode 100755
index dfa2c09..0000000
--- a/local/bin/system-backup
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-# vim:ft=sh
-# New line separated list of all directories to backup
-DIRS="/etc
-/home
-/home_hdd"
-# Name of the machine used in backup subvolumes
-MNAME=asus
-# Path where backup will be mounted
-MPATH=/media/backup
-# UUID of disk
-UUID=b162ea95-38bb-42c6-b36a-1be98c65392c
-# Mount additional arguments
-MARGS="-o compress=lzo"
-# If disk is encrypted
-CRYPT=true
-####################################################################
-# Check if running as root
-if [ `id -u` -ne "0" ]; then
- echo Please run this as root.
- exit 1
-fi
-set -e
-
-# Mount disk
-PART=$(lsblk -fpl | grep "$UUID" | awk '{print $1}')
-if [ -z "$PART" ]; then
- echo Disk not detected. Exiting
- exit -1
-fi
-if $CRYPT; then
- echo -e "\e[1;33mDecrypting filesystem\e[0m"
- # TODO what if already opened
- cryptsetup open "$PART" backup || (echo Decryption failed && exit -2)
- PART=/dev/mapper/backup
- echo $PART
-fi
-echo -e "\e[1;33mMounting\e[0m"
-mkdir -p "$MPATH"
-mount $MARGS "$PART" "$MPATH" || (echo Mount failed && exit -3)
-
-[ -d "$MPATH"/@"$MNAME" ] || (echo There seems to be no subvolume $MNAME && exit -4)
-
-# Do backup
-while read -r DIR; do
- echo -e "\e[1;33mBacking up: $DIR\e[0m"
- rsync -aAxXS --delete --progress "$DIR" "$MPATH"/@"$MNAME"/ || [ $? -eq 24 ]
- # We ignore exit code if rsync detects vanished source file
-done <<< "$DIRS"
-
-# Do snapshot (read only)
-(cd "$MPATH"; btrfs subvolume snapshot -r @asus @asus-$(date -u +%y%m%d))
-
-# Remove snapshots older than 2 months
-# TODO ensure that at least five stays
-(cd "$MPATH"
-for s in @"$MNAME"-*; do
- if [ $(expr $(date +%s) - $(stat -c %Y "$s")) -gt 5529600 ]; then
- btrfs subvolume delete "$s"
- fi
-done)
-
-# Unmount disk
-sync -f "$MPATH"/@"$MNAME"
-umount "$MPATH" || (echo Unmount failed. Unmount by hand. && exit -5)
-if $CRYPT; then
- cryptsetup close backup || (echo Encryption close failed. Do by hand. && exit -6)
-fi
-
-# Store when we did last backup and update i3blocks status
-date +"%s" > /home/cynerd/.backup_date
-pkill -RTMIN+13 i3blocks
-
-echo
-echo -e "\e[1;34mBackup finished\e[0m"
diff --git a/local/bin/vim-project-gen b/local/bin/vim-project-gen
deleted file mode 100755
index 6a50ba5..0000000
--- a/local/bin/vim-project-gen
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-# Generates ctags and cscope files for project.
-ctags -R -f .tags
-#cscope -Rbq -f .cscope.out
diff --git a/local/bin/xshot b/local/bin/xshot
deleted file mode 100755
index 90f91af..0000000
--- a/local/bin/xshot
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-import -window "$(xdotool selectwindow)" ~/xshot_$(date +%F_%H%M%S_%N).png
diff --git a/local/sbin/newmail-notify b/local/sbin/newmail-notify
deleted file mode 100755
index 7c6b803..0000000
--- a/local/sbin/newmail-notify
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-cd ~/.mail
-
-if [ -f notify-notified ]; then
- NOTIFIED=`cat notify-notified`
- rm notify-notified
-fi
-
-for account in `ls`; do
- if cd "$account"/INBOX/new; then
- for m in `ls`; do
- echo $m
- echo $m >> ~/.mail/notify-notified
- if echo "$NOTIFIED" | grep "$m" >/dev/null; then continue; fi
- FROM=`grep -E "^From: " "$m" | sed 's/^From: //' | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)'`
- TO=`grep -E "^To: " "$m" | sed 's/^To: //' | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)'`
- SUBJECT=`grep -E "^Subject: " "$m" | sed 's/^Subject: //' | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)'`
- notify-send "$TO: $FROM" "$SUBJECT"
- done
- fi
- cd ~/.mail
-done
diff --git a/local/sbin/syncemail b/local/sbin/syncemail
deleted file mode 100755
index 3cb56a4..0000000
--- a/local/sbin/syncemail
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/python2
-# This starts offlineimap, but first it requests passwords from pass
-import os
-import sys
-import subprocess
-import daemon
-import lockfile
-import syslog
-from offlineimap import OfflineImap
-
-pidfile = '/tmp/syncemail-%d.pid' % os.getuid()
-
-# Check if not already running
-def check_running():
- if os.access(pidfile, os.F_OK):
- with open(pidfile, "r") as f:
- pid = f.readline()
- if os.path.exists('/proc/%s' % pid):
- sys.exit(0)
-check_running()
-
-
-accounts = [
- ["email", "mail/cynerd@email.cz"],
- ]
-
-for acc in accounts:
- pproc = subprocess.Popen("pass " + acc[1],
- stdout=subprocess.PIPE, shell=True)
- output = pproc.stdout.read().rstrip()
- if pproc.wait() != 0:
- print("Password receive failed.")
- sys.exit(1)
- sys.argv.append('-k')
- sys.argv.append('Repository_' + acc[0] + '-remote:remotepass=' + output)
-
-# 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/local/sbin/user-service.sh b/local/sbin/user-service.sh
deleted file mode 100755
index e48bb9d..0000000
--- a/local/sbin/user-service.sh
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/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