summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbackup-www21
-rwxr-xr-xf7-script.sh107
-rwxr-xr-xpsgrep3
-rwxr-xr-xsibsac-vpn21
-rwxr-xr-xxcf2jpeg11
5 files changed, 160 insertions, 3 deletions
diff --git a/backup-www b/backup-www
new file mode 100755
index 0000000..440a060
--- /dev/null
+++ b/backup-www
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+set -e
+
+die() {
+ echo $1 >&2
+ exit 1
+}
+
+# File contains key variable definition.
+. "$HOME/.backup-www"
+[[ -z "$key" ]] && die 'No $key definition.'
+
+name="backup-$(date --rfc-3339=seconds | cut -c -19 | tr ': ' '-_').des3"
+
+sudo find /etc /home/anton /var/www ! -name 'backup-*.des3' -print0 |\
+ sudo cpio --create --dot --null |\
+ openssl enc -des3 -k "$key" > "$name"
+sha512sum "$name" > "$name.sha512sum"
+scp "$name"* gd.bobov.name:
+echo "File name: $name"
diff --git a/f7-script.sh b/f7-script.sh
new file mode 100755
index 0000000..ab3178b
--- /dev/null
+++ b/f7-script.sh
@@ -0,0 +1,107 @@
+#!/bin/bash
+
+set -e
+
+INTERNAL=LVDS1
+EXTERNAL=VGA1
+
+show_usage() {
+ cat <<END
+Screen switch helper script.
+
+Usage: $0 <command>
+
+ commands:
+ toggle
+ external
+ internal
+ mirror
+
+END
+}
+
+screen_external() {
+ xrandr --output "$INTERNAL" --off
+ xrandr --output "$EXTERNAL" --auto
+}
+screen_internal() {
+ xrandr --output "$EXTERNAL" --off
+ xrandr --output "$INTERNAL" --auto
+}
+screen_mirror() {
+ xrandr --output "$INTERNAL" --auto
+ xrandr --output "$EXTERNAL" --auto --same-as "$INTERNAL"
+}
+
+screen_toggle() {
+ case "$STATE" in
+ internal)
+ screen_external
+ ;;
+ external)
+ screen_internal
+ ;;
+ mirror)
+ screen_external
+ ;;
+ *)
+ screen_internal
+ ;;
+ esac
+}
+
+
+screen_get_state() {
+ SCREEN="$1"
+ xrandr --query | grep "^$SCREEN"
+ #xrandr --query | grep "^$SCREEN" | grep connected | sed 's/.*connected\s*\([^ ]\+\).*/\1/' | grep -o '[0-9]*x[0-9]*' || echo
+}
+is_connected() {
+ echo "$1" | grep ' connected' >/dev/null && echo 1 || echo
+}
+is_active() {
+ echo "$1" | grep connected | sed 's/.*connected\s*\([^ ]\+\).*/\1/' | grep -o '[0-9]*x[0-9]*' || echo
+}
+
+INTERNAL_STATE=$(screen_get_state "$INTERNAL")
+EXTERNAL_STATE=$(screen_get_state "$EXTERNAL")
+
+EXTERNAL_CONNECTED=$(is_connected "$EXTERNAL_STATE")
+
+if [ -z "$EXTERNAL_CONNECTED" ] ; then
+ echo "External monitor $EXTERNAL not connected." >&2
+ exit 0
+fi
+
+INTERNAL_STATE=$(is_active "$INTERNAL_STATE")
+EXTERNAL_STATE=$(is_active "$EXTERNAL_STATE")
+if [ -z "$INTERNAL_STATE" ] ; then
+ STATE="external"
+elif [ -z "$EXTERNAL_STATE" ] ; then
+ STATE="internal"
+else
+ STATE="mirror"
+fi
+
+DO="$1"
+if [ -z "$DO" ] ; then
+ DO="toggle"
+fi
+
+case "$DO" in
+ toggle)
+ screen_toggle
+ ;;
+ internal)
+ screen_internal
+ ;;
+ external)
+ screen_external
+ ;;
+ mirror)
+ screen_mirror
+ ;;
+ *)
+ show_usage >&2
+ ;;
+esac
diff --git a/psgrep b/psgrep
deleted file mode 100755
index f3ead37..0000000
--- a/psgrep
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-ps aux | grep -e "$1" | grep -v grep
diff --git a/sibsac-vpn b/sibsac-vpn
new file mode 100755
index 0000000..7fb26bf
--- /dev/null
+++ b/sibsac-vpn
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+set -e
+
+if [[ $(/usr/bin/id -u) -ne 0 ]] ; then
+ echo Not running as root
+ exit
+fi
+
+echo Connection to the VPN
+vpnc sibsac
+
+echo Press any key to disconnect ...
+
+read $disconnect
+
+echo Disconnection from the VPN
+vpnc-disconnect
+
+echo VPN should now be disconnected
+
diff --git a/xcf2jpeg b/xcf2jpeg
index 5f460b3..56866bb 100755
--- a/xcf2jpeg
+++ b/xcf2jpeg
@@ -5,6 +5,7 @@ SELFNAME=$(basename $0)
SIZE=800
QUALITY=95
OVERWRITE=0
+OUTPUT_DIR=
GIMP="gimp"
die()
@@ -25,6 +26,8 @@ Options:
-q, --quality JPEG image quality in percents (0-100) (default: $QUALITY)
-f, --force force convert, even if result file exists
-h, --help print this help
+ --output-dir name of output directory where place files. By default files
+ placed in same directory with source.
Example:
Convert all XCF files in directory
@@ -55,6 +58,10 @@ do
-f|--force)
OVERWRITE=1
;;
+ --output-dir)
+ OUTPUT_DIR="$2"
+ shift
+ ;;
*)
die "Error: Unknown option: $1"
;;
@@ -104,6 +111,10 @@ for file
do
FILENAME=$file
OUT_FILENAME=${FILENAME%%.xcf}.jpg
+ if [[ -n "$OUTPUT_DIR" ]]
+ then
+ OUT_FILENAME="$OUTPUT_DIR/$(basename "$OUT_FILENAME")"
+ fi
if [[ $OVERWRITE = 0 && -f "$OUT_FILENAME" ]]
then
printf "Warning: File $OUT_FILENAME exists, skipping.\n" >&2