diff options
Diffstat (limited to 'local')
-rwxr-xr-x | local/bin/asus-fan | 28 | ||||
-rwxr-xr-x | local/bin/email-unread | 33 | ||||
-rwxr-xr-x | local/bin/lxc-net | 41 | ||||
-rwxr-xr-x | local/bin/mxrandr | 119 | ||||
-rwxr-xr-x | local/bin/project-test | 43 | ||||
-rwxr-xr-x | local/bin/steam | 10 | ||||
-rwxr-xr-x | local/bin/surf-menu | 60 | ||||
-rwxr-xr-x | local/bin/system-backup | 75 | ||||
-rwxr-xr-x | local/bin/usbkey | 245 | ||||
-rwxr-xr-x | local/bin/vim-project-gen | 4 | ||||
-rwxr-xr-x | local/sbin/newmail-notify | 23 | ||||
-rwxr-xr-x | local/sbin/syncemail | 48 | ||||
-rwxr-xr-x | local/sbin/user-service.sh | 106 |
13 files changed, 0 insertions, 835 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/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/project-test b/local/bin/project-test deleted file mode 100755 index a0591d8..0000000 --- a/local/bin/project-test +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# Executes given command on all commits from current one to given one. -set -e - -print_help() { - echo "Executes given command for each commit. In default it executes" - echo "for 10 previous commands." - echo - echo "Usage: project-test [OPTION...] [--] COMMAND" - echo " -r,--ref [REF]" - echo " Git reference to go to" - echo " -c,--count [COUNT]" - echo " Tests given count of references back from current one." -} - -while [ -n "$1" ]; do - case $1 in - -r|--ref) - shift - REF=$1 - ;; - -c|--count) - shift - REF=HEAD~$1 - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -[ -n "$REF" ] || REF=HEAD~10 - -while read -r rev; do - git checkout "$rev" - git submodule update - eval $@ -done < <(git rev-list "$REF"..HEAD) 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/surf-menu b/local/bin/surf-menu deleted file mode 100755 index b2e0111..0000000 --- a/local/bin/surf-menu +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -set -e - -BOOKMARDS=~/notes/bookmarks.md - -run() { - echo "Run $1" - echo "$1" | grep -qE '^~?/' || true - echo $? - if echo "$1" | grep -qE '^\?'; then # We do search on duckduckgo - - surf "https://duckduckgo.com/?q=${L#?}&t=surf&kk=-1&ia=web" & - - elif echo "$1" | grep -qE '^~?/'; then # This is local path - - surf "${1/#\~/$HOME}" & - - elif echo "$1" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'; then # This ipv4 address - - surf "$1" & - - else # We follow address - - LPROTOCOL="$(echo "$1" | sed -n 's#^\([^:]*\)://.*#\1#p')" - LHOST="$(echo "$1" | sed -n 's#^[^:]*://##;s#^\([^/]\+\)/\?.*#\1#p')" - LPATH="$(echo "$1" | sed 's#^[^:]*://##;s#^[^/]\+/\?##')" - - if ! getent hosts "$LHOST" >/dev/null; then - if getent hosts "$LHOST.cz" >/dev/null; then - LHOST="$LHOST.cz" - elif getent hosts "$LHOST.org" >/dev/null; then - LHOST="$LHOST.org" - elif getent hosts "$LHOST.com" >/dev/null; then - LHOST="$LHOST.com" - fi - # TODO what to do when we can't expand it? - fi - # Decide on protocol (if connection to 443 is not possible then use http otherwise https) - if [ -z "$LPROTOCOL" ]; then # We already have protocol (given explicitly) - if nc -z -w1 "$LHOST" 443 2>/dev/null; then - LPROTOCOL="https" - else - LPROTOCOL="http" - fi - fi - - surf "$LPROTOCOL://$LHOST/$LPATH" & - - fi -} - -if [ -n "$1" ]; then - run "$1" - exit -else - # Note: Bookmarks starts with '* ' - sed -n 's/\* //p' "$BOOKMARDS" | dmenu -p 'surf' | while read L; do - run "$L" - done -fi 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/usbkey b/local/bin/usbkey deleted file mode 100755 index e6cc42e..0000000 --- a/local/bin/usbkey +++ /dev/null @@ -1,245 +0,0 @@ -#!/bin/sh -set -e - -UUID_KKEY="7930cd94-b56e-4395-8859-f34da77f29be" -UUID_WKEY="9fcaf42a-86d5-4e70-828d-fd90aad2d964" - -CRYPT_NAME="usbkey" -MOUNT_PATH="/media/usbkey" - -op_mount() { - # First check if we have key drive - if [ ! -e "/dev/disk/by-uuid/$UUID_KKEY" ]; then - echo "Can't locate appropriate usb drive." >&2 - exit 1 - fi - # Decrypt drive - if [ -e "/dev/mapper/$CRYPT_NAME" ]; then - echo "USB key seems to be already decrypted" >&2 - else - echo "Decrypting usb key" >&2 - sudo -- cryptsetup open /dev/disk/by-uuid/"$UUID_KKEY" "$CRYPT_NAME" - fi - # Mount drive - if mount | grep -q "$MOUNT_PATH"; then - echo "USB key is already mounted" >&2 - else - echo "Mounting usb key" - sudo -- mkdir -p "$MOUNT_PATH" - sudo -- mount -o uid="$(id -u)",gid="$(id -g)" "/dev/mapper/$CRYPT_NAME" "$MOUNT_PATH" - fi - - echo "USB key drive mounted" >&2 -} - -op_unmount() { - # Unmount - if mount | grep -q "$MOUNT_PATH"; then - echo "Unmounting usb key" >&2 - sync "$MOUNT_PATH" - sudo -- umount "$MOUNT_PATH" - fi - # Remove mount path - [ ! -d "$MOUNT_PATH" ] || sudo -- rmdir "$MOUNT_PATH" - # Close encryption - if [ -e "/dev/mapper/$CRYPT_NAME" ]; then - echo "Closing encryption on usb key" >&2 - sudo -- cryptsetup close "$CRYPT_NAME" - fi - - echo "USB key unmounted" >&2 -} - -check_mount() { - mount | grep "$MOUNT_PATH" | grep -q "/dev/mapper/$CRYPT_NAME" -} - -op_sync() { - local DOUNMOUNT=false - if [ ! -e "/dev/disk/by-uuid/$UUID_WKEY" ]; then - echo "USB backup key seems to not be inserted. Please do so." >&2 - exit 1 - fi - if ! check_mount; then - DOUNMOUNT=true - op_mount - fi - - # Mount backup usb - sudo -- cryptsetup open "/dev/disk/by-uuid/$UUID_WKEY" "$CRYPT_NAME-backup" - sudo -- mkdir -p "$MOUNT_PATH-backup" - sudo -- mount -o uid="$(id -u)",gid="$(id -g)" "/dev/mapper/$CRYPT_NAME-backup" "$MOUNT_PATH-backup" - # Sync them - rsync -ax --delete --progress "$MOUNT_PATH/" "$MOUNT_PATH-backup/" - # Unmount it - sudo -- umount "$MOUNT_PATH-backup" - sudo -- rmdir "$MOUNT_PATH-backup" - sudo -- cryptsetup close "$CRYPT_NAME-backup" - - if $DOUNMOUNT; then - op_unmount - fi - - echo "Sync process finished." >&2 -} - -op_gpg_import() { - # TODO - true -} - -op_ssh_list() { - check_mount || op_mount - for KEY in $(find "$MOUNT_PATH/ssh" -name '*.pub'); do - local N="${KEY#$MOUNT_PATH/ssh/}" - echo -n "${N%.pub}: " - sed -n 's/ssh-rsa [^ ]* \(.*\)/\1/p' "$KEY" - done -} - -check_name() { - if [ -z "$NAME" ]; then - echo "You have to specify key name!" >&2 - exit 1 - fi -} - -op_ssh_generate() { - check_name - check_mount || op_mount - if [ -f "$MOUNT_PATH/ssh/$NAME" ]; then - echo "Key $NAME seems to already exists." >&2 - exit 1 - fi - echo -n "Please enter comment: " - read COMMENT - ssh-keygen -f "$MOUNT_PATH/ssh/$NAME" -C "$COMMENT" - - echo "SSH key $NAME was generated." >&2 -} - -op_ssh_import() { - check_name - check_mount || op_mount - if [ ! -f "$MOUNT_PATH/ssh/$NAME" ] || [ ! -f "$MOUNT_PATH/ssh/$NAME.pub" ]; then - echo "There is no key named $NAME" >&2 - exit 1 - fi - cp "$MOUNT_PATH/ssh/$NAME" ~/.ssh/ - cp "$MOUNT_PATH/ssh/$NAME.pub" ~/.ssh/ - chmod 600 ~/.ssh/"$NAME" - chmod 640 ~/.ssh/"$NAME.pub" - - echo "SSH key $NAME copied to local .ssh directory." >&2 -} - -# Note OpenVPN: CA generated using following command -# openssl req -nodes -new -x509 -days 3650 -keyout ca.key -out ca.crt -config openssl.cnf - -op_openvpn_list() { - check_mount || op_mount - for KEY in $(find "$MOUNT_PATH/openvpn" -name 'ca.crt' -o -name '*.crt' -print); do - local N="${KEY#$MOUNT_PATH/openvpn/}" - echo "${N%.crt}" - done -} - -op_openvpn_get() { - check_name - check_mount || op_mount - if [ ! -f "$MOUNT_PATH/openvpn/$NAME.key" ] || [ ! -f "$MOUNT_PATH/openvpn/$NAME.crt" ]; then - echo "There is no OpenVPN key $NAME" >&2 - exit 1 - fi - mkdir "openvpn-$NAME" - cp "$MOUNT_PATH/openvpn/$NAME.key" "openvpn-$NAME/" - cp "$MOUNT_PATH/openvpn/$NAME.crt" "openvpn-$NAME/" - cp "$MOUNT_PATH/openvpn/ca.crt" "openvpn-$NAME/" - cp "$MOUNT_PATH/openvpn/ta.key" "openvpn-$NAME/" - - echo "OpenVPN key $NAME copied to openvpn-$NAME directory." >&2 -} - -op_openvpn_generate() { - check_name - check_mount || op_mount - if [ -f "$MOUNT_PATH/openvpn/$NAME.key" ] && [ -f "$MOUNT_PATH/openvpn/$NAME.crt" ]; then - echo "OpenVPN key $NAME seems to already exists" >&2 - exit 1 - fi - ( - cd "$MOUNT_PATH/openvpn" - # Build request - openssl req -days 3650 -nodes -new -config "openssl.cnf" \ - -keyout "$NAME.key" -out "$NAME.csr" - # Sign request - openssl ca -days 3650 -config "openssl.cnf" \ - -out "$NAME.crt" -in "$NAME.csr" - ) - - echo "OpenVPN key $NAME was generated." >&2 -} - - -unknown_argument() { - echo "Unknown argument: $1" - exit 1 -} -# Parse operation (operation have to be first) -case "$1" in - -h|--help) - echo "Usb key manager" - echo "Usage: usbkey OPERATION ..." - echo - echo "Operations:" - echo " mount: Mount key of usb driver" - echo " unmount: Unmount usb driver" - echo " sync: Synchronize drive to bakup drive" - echo " gpg-import: Import gpg key" - echo " ssh-import: Import ssh key" - echo " ssh-generate: Generate new ssh key" - echo " ssh-list: List all ssh keys in store" - echo " openvpn-list: List all openvpn keys" - echo " openvpn-get: Get openvpn keys for some host" - echo " openvpn-generate: Generate openvpn key for new host" - exit 0 - ;; - mount|unmount|sync|gpg-import|ssh-import|ssh-generate|ssh-list|openvpn-list|openvpn-get|openvpn-generate) - OPERATION="$1" - ;; - *) - unknown_argument "$1" - ;; -esac -shift -# Parse rest of the arguments -while [ $# -gt 0 ]; do - case "$1" in - -h|--help) - echo "Usb key manager" - case "$OPERATION" in - mount|unmount|sync|ssh-list|openvn-list) - echo "Usage: usbkey $OPERATION [-h]" - ;; - ssh-*|openvpn-*) - echo "Usage: usbkey $OPERATION NAME [-h]" - ;; - # TODO - esac - exit 0 - ;; - *) - if [ -z "$NAME" ] && \ - [ "$OPERATION" = "ssh-import" -o "$OPERATION" = "ssh-generate" -o \ - "$OPERATION" = "openvpn-get" -o "$OPERATION" = "openvpn-generate" ] \ - ; then - NAME="$1" - else - unknown_argument "$1" - fi - ;; - esac - shift -done -# Go to operation handler -eval "op_$(echo "$OPERATION" | tr '-' '_')" 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/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 632272c..0000000 --- a/local/sbin/user-service.sh +++ /dev/null @@ -1,106 +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" - echo " ifrestart - restart service if it's running" - ;; - -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 - ;; - ifrestart) - $Q && echo "Restarting service $NAME..." - if status; then - if ! stop; then - $Q && echo " stop failed" - exit 1 - fi - if start; then - $Q && echo " ok" - else - $Q && echo " start failed" - exit 1 - fi - fi - ;; - *) - echo "Invalid operation!" - exit 3 - ;; -esac |