summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Bobov <abobov@gmail.com>2018-11-01 22:16:21 +0500
committerAnton Bobov <abobov@gmail.com>2018-11-01 22:16:21 +0500
commit2bf34f4efd5643b847170443ca9aa03dafed976c (patch)
treeed4f121a91f6a5f3214e4cea25c47475abd9e86d
parent88fcd4ab2ea43395da996ccfe067b3b5651eb458 (diff)
Update bin.
-rwxr-xr-xbackup-lima41
-rwxr-xr-xbang.sh8
-rwxr-xr-xd-backup59
-rwxr-xr-xeditinvim.sh8
-rwxr-xr-xhw-report14
-rwxr-xr-xxe39
6 files changed, 106 insertions, 63 deletions
diff --git a/backup-lima b/backup-lima
deleted file mode 100755
index e1557d9..0000000
--- a/backup-lima
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-
-set +e
-
-DEST=anton@bonn:/mnt/mirror/backup/lima
-
-{
- echo /bin
- echo /core
- echo /dev
- echo /home/anton/Music
- echo /home/anton/Videos
- echo /home/anton/VirtualBox VMs/
- echo /home/anton/.cache
- echo /home/anton/.thumbnails
- echo /home/anton/.local/share/Trash
- echo /home/anton/.m2
- echo /initrd.img
- echo /initrd.img.old
- echo /lib
- echo /lib32
- echo /lib64
- echo /lost+found
- echo /media
- echo /misc
- echo /mnt
- echo /proc
- echo /run
- echo /sbin
- echo /selinux
- echo /srv
- echo /swap
- echo /sys
- echo /tmp
- echo /usr
- echo /var/tmp
- echo /var/cache
- echo /var/lib
- echo /vmlinuz
- echo /vmlinuz.old
-} | sudo rsync --archive --verbose --compress --progress --human-readable --delete --delete-excluded --exclude-from=- -xdev -e "ssh -i $HOME/.ssh/id_rsa" / /home "$DEST"
diff --git a/bang.sh b/bang.sh
index 263c164..1d960d7 100755
--- a/bang.sh
+++ b/bang.sh
@@ -4,9 +4,5 @@ set -e
FILE=/usr/share/orage/sounds/Spo.wav
-if [ ! -f "$FILE" ] ; then
- echo "No sound file: $FILE"
- exit 1
-fi
-
-aplay --quiet "$FILE"
+which notify-send >/dev/null 2>&1 && notify-send "Task done"
+[ -f "$FILE" ] && aplay --quiet "$FILE"
diff --git a/d-backup b/d-backup
new file mode 100755
index 0000000..090b672
--- /dev/null
+++ b/d-backup
@@ -0,0 +1,59 @@
+#!/bin/bash
+#
+# Example content of duplicity.conf, keep file root:root and only owner 0600
+# ---------------- 8< --------------------
+# FTP_PASSWORD="ftp_password"
+# PASSPHRASE="passphrase"
+# TARGET="sftp://server/path"
+# ---------------- 8< --------------------
+
+if [ ! $(whoami) = root ] ; then
+ echo "This script must be run by the user: root"
+ exit 1
+fi
+
+HOME=/home/anton
+
+source "$HOME/.duplicity.conf"
+SOURCE=/
+
+print_help() {
+ cat <<EOF
+Commands:
+ backup run backup
+ stats show collection status
+EOF
+}
+
+backup() {
+ duplicity cleanup --force "$TARGET"
+ duplicity \
+ --exclude-filelist "$HOME/.duplicity-exclude" \
+ --full-if-older-than 2M \
+ "$SOURCE" "$TARGET"
+}
+
+stats() {
+ duplicity collection-status "$TARGET"
+}
+
+if [[ $# = 0 ]] ; then
+ print_help
+ exit 0
+fi
+
+while (( "$#" )) ; do
+ case "$1" in
+ backup)
+ backup
+ ;;
+ stats)
+ stats
+ ;;
+ *)
+ print_help
+ ;;
+ esac
+ shift
+done
+
diff --git a/editinvim.sh b/editinvim.sh
new file mode 100755
index 0000000..832c3bf
--- /dev/null
+++ b/editinvim.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+# https://snippets.martinwagner.co/2018-03-04/vim-anywhere
+
+file=$(mktemp)
+gvim --nofork "$file"
+
+xdotool type --delay 0 --file "$file"
+rm "$file"
diff --git a/hw-report b/hw-report
new file mode 100755
index 0000000..790f0d9
--- /dev/null
+++ b/hw-report
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+
+if hash lshw 2>/dev/null ; then
+ report="lshw-$(hostname)-$(date +%F)"
+ report_txt="$report.txt"
+ report_html="$report.html"
+ sudo lshw > "$report_txt" 2>/dev/null
+ sudo lshw -html > "$report_html" 2>/dev/null
+else
+ echo No lshw command.
+ exit 1
+fi
diff --git a/xe b/xe
index 7612164..97dc724 100755
--- a/xe
+++ b/xe
@@ -6,25 +6,32 @@ if [ $# = 0 ] ; then
exit 0
fi
+if ! (hash phantomjs >/dev/null 2>&1) ; then
+ exit 1
+fi
+
from=${1:0:3}
to=${1:3:3}
get_value() {
- curl -s "http://www.xe.com/currencyconverter/convert/?Amount=1&From=$from&To=$to" | \
- grep -o "<span class='uccResultAmount'>[^<]\+" | \
- grep -o '[0-9\.]\+'
-}
-
-get_value_at_date() {
- date=$(date -d "$1" +%F)
- curl -s "http://www.xe.com/currencytables/?from=$from&date=$date" | \
- xmllint --nonet --html --xpath "//table[@id='historicalRateTbl']/tbody/tr[td/a/text() = '${to^^}']/td[3]/text()" - 2>/dev/null
+ script=$(tempfile)
+ url="http://www.xe.com/currencyconverter/convert/?Amount=1&From=$from&To=$to"
+ cat <<EOF >$script
+ var page = require('webpage').create();
+page.open('$url', function(status) {
+ if (status !== 'success') {
+ console.log('Unable to access network');
+ } else {
+ var ua = page.evaluate(function() {
+ return document.querySelector('.converterresult-toAmount').textContent;
+ });
+ console.log(ua);
+ }
+ phantom.exit();
+});
+EOF
+ timeout 15s phantomjs $script | head -n 1
+ rm $script
}
-if [ -z "$2" ] ; then
- val=$(get_value)
-else
- val=$(get_value_at_date "$2")
-fi
-
-printf '%.4f\n' $val
+get_value $from $to