Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
DIR_NAMES=( "www.domain1.org" "www.domain1.org" );
cd ${1:-./}
for DIR_NAME in "${DIR_NAMES[@]}"; do
echo ok
DIR_ID=`gdrive list -m 500 -q "sharedWithMe = true" | grep -i ${DIR_NAME} | awk '{ print $1 }'`
gdrive download --recursive --force ${DIR_ID}
done
@aenniw
aenniw / netlink-reset.html
Created June 2, 2017 13:28
Netlink-D300 password reset
@aenniw
aenniw / ocserv-dns.sh
Last active May 9, 2022 08:23
Automatically set hostname for OpenConnects VPN clients on OpenWRT
#!/bin/sh
# Set fields in /etc/ocsercv/ocserv.conf.template as below
#
# connect-script = /path/to/vpn-hostnames.sh
# disconnect-script = /path/to/vpn-hostnames.sh
# Set field in /etc/config/dhcp as below
#
# config dnsmasq
@aenniw
aenniw / watch.sh
Last active June 6, 2017 15:48 — forked from mikesmullin/watch.sh
watch is a linux bash script to monitor file modification recursively and execute bash commands as changes occur
#!/usr/bin/env bash
# script: watch
# author: Mike Smullin <mike@smullindesign.com>
# license: GPLv3
# description:
# watches the given path for changes
# and executes a given command when changes occur
# usage:
# watch <path> <cmd...>
#
@aenniw
aenniw / divide-and-conquer.sh
Last active February 3, 2023 12:59
Bash Divide&Conquer scripts
#!/usr/bin/env bash
TASK_LIMIT=4
# ########################## HOW-TO ########################################## #
# 1. Include in your script with source <(curl -s <URL>) #
# 2. Override max simultaneous workers by TASK_LIMIT #
# 3. Define func1 that will generate workers data/ atleast their ids #
# 4. Define func2 that will contain logic to handle segmet of worker #
# 5. Define func3 that will agregate computed results #
# 6. Run divide_and_conquer func1 func2 func2 and wait for script to end #
@aenniw
aenniw / display-buttons.py
Last active July 23, 2018 05:04
Waveshare 3.2' [Clone] Buttons handling
#!/usr/bin/env python
# sudo apt-get install python-dev python-rpi.gpio
import RPi.GPIO as GPIO
from time import sleep
import signal, os
buttons = [24, 23, 18]
GIST_PROFILE_PATH=~/.bash_profile_gist
GIST_PROFILE_URI=https://gist.githubusercontent.com/aenniw/7f1883a867e5d551b9c859eba176b6b3/raw/.bash_profile_gist
function update-gist() {
curl -s ${GIST_PROFILE_URI} 2>/dev/null > ${GIST_PROFILE_PATH}
}
function resource-gist() {
test -f ${GIST_PROFILE_PATH} && \
source ${GIST_PROFILE_PATH}
#!/bin/bash
# Usage: USER=user PASSWD=secret volumio2-ui-basic-auth.sh or
# volumio2-ui-basic-auth.sh for default user volumio:volumio
sudo su || exit 1
apt-get install apache2-utils nginx
htpasswd -cb /etc/nginx/.htpasswd ${USER:-volumio} ${PASSWD:-volumio}
@aenniw
aenniw / install-acme-openwrt.sh
Last active July 17, 2019 12:01
Setup letsencrypt for ocserv on OpenWRT
#!/bin/sh
SINGLE_DOMAIN=${SINGLE_DOMAIN:-my.domain.org}
opkg install ca-certificates ca-bundle curl
hash acme.sh || ( curl https://get.acme.sh | sh && \
ln -s /root/.acme/acme.sh /usr/bin/ )
acme.sh --issue -d ${SINGLE_DOMAIN} --dns --force
@aenniw
aenniw / volumio-album-art.sh
Last active July 17, 2018 20:04
Show Volumio2 album thumbnail on ILI9341 based display.
#!/bin/bash
# DEPENDENCIES
# apt-get -y install fbi curl
# PINOUT: Display -> Raspberry Pi Zero
# BL -> pin 12 (GPIO 18)
# SCK -> pin 23 (GPIO 11)
# MISO -> pin 21 (GPIO 9)
# MOSI -> pin 19 (GPIO 10)