Skip to content

Instantly share code, notes, and snippets.

View wernerb's full-sized avatar
🏠
Working from home

Werner Buck wernerb

🏠
Working from home
View GitHub Profile
#!/bin/bash
set +u
shopt -s xpg_echo
shopt -s expand_aliases
unset PATH JAVA_HOME LD_LIBRARY_PATH
function abort {
echo "aborting: $@" 1>&2
exit 1
}
function default {
@wernerb
wernerb / async.sh
Created June 29, 2014 21:25
Executes commands asynchronously while keeping stdout/stderr. Does not use tail -f, stops when the command stops. Works in POSIX shells.
############
# Executes commands asynchronously while keeping stdout/stderr.
# If the shell quits or fails then the script can be started again and it
# will read in stdout again from the beginning and continue.
#
# Author: Werner Buck
############
# Command to execute asynchronously.
### Keybase proof
I hereby claim:
* I am wernerb on github.
* I am buck (https://keybase.io/buck) on keybase.
* I have a public key whose fingerprint is 82BA F93B ADC2 9352 411B D2D2 2E3F 8B94 6AF1 B74E
To claim this, I am signing this object:
@wernerb
wernerb / keybase.md
Created March 24, 2014 21:29
My keybase.io proof

Keybase proof

I hereby claim:

  • I am wernerb on github.
  • I am buck (https://keybase.io/buck) on keybase.
  • I have a public key whose fingerprint is 70BB 5523 42D5 3EC8 C22D F4C5 3634 04C4 8767 E6F6

To claim this, I am signing this object:

@wernerb
wernerb / sync.sh
Last active September 4, 2023 18:02
Sync folder with Google Drive. Recursively downloads with wget and Google Drive public links. Used to sync ebooks to my eReaders (Kobo). Be warned that public links are dangerous as they could allow someone to download your files. Be sure to use this only in secure environments. This has been tested to be used in POSIX shells as well as in bash.
#!/bin/sh
#input sharelink here. Example: https://drive.google.com/folderview?id=0B1g-MbiD2F6vdtOT92b3MoerO&usp=sharing
SHARELINK="https://drive.google.com/folderview?id=idU&usp=sharing"
DESTINATION="/full/path/to/folder"
# Change following to false when you don't want to delete files when they are missing from google drive. This can
REMOVEFILES=true
# Begin code
@wernerb
wernerb / wgetmirror.sh
Last active December 27, 2015 23:29
Uses strictly wget and grep to mirror a remote HTTP location recursively. Deletes old files. Supports http auth and self-signed certificates. Strictly POSIX compliant so that it works in "dash" as well as in "bash". Handy to use on arm devices that need syncing but do not have rsync or ssh. Currently used to sync multiple kobo ereaders.
#!/bin/bash
################ CONFIG ###################
username="user"
#HTTP Auth username
password="password"
#HTTP Auth password
basedirname="/directory/to/Sync"
#CA certificate in PEM format
certificate="/directory/to/cert.crt"
#url = Set to the https server running an nginx or apache file listing. Make sure its urlencoded and don't forget trailing slash.