Skip to content

Instantly share code, notes, and snippets.

@idodeclare
idodeclare / auto_home.sh
Last active April 25, 2020 01:12
OmniTI's auto_home.sh script
#!/bin/bash
# Script to automatically create home directories on demand, and mount them
# from BASE (default /export/home)
BASE=/export/home
ID=$(/bin/id $1 2>/dev/null)
if [[ -n "$ID" ]]; then
if [[ ! -d "$BASE/$1" ]]; then
DSET=$(/usr/sbin/zfs list -H -o mountpoint,zoned,name | gawk -v base=$BASE -v zone=$(zonename) '$1==base && ( $2=="off" || zone != "global" ) { print $3 }')
if [[ -n "$DSET" ]]; then
/usr/sbin/zfs create $DSET/$1
#!/bin/sh
keylength=8
algo=$1
[[ "$algo" = "aes" ]] && keylength=16
[[ "$algo" = "3des" ]] && keylength=24
encfile=$(mktemp -t _encXXXXXX) && \
keyfile=$(mktemp -t _encXXXXXX) && \
dd if=/dev/urandom of="$keyfile" bs="$keylength" count=1 >/dev/null 2>&1 && \
@idodeclare
idodeclare / gist:9829000b05f7e7c0427a72e0c20d13b6
Created November 2, 2016 21:57
Find Makefiles using target-group syntax
find usr/ -name Makefile \
| xargs perl -nle 'BEGIN { undef $/ }
my @m = /^(?![#\.]) (\S[^:=\n]+?:)/mgx;
foreach my $m (grep { /\+/ } @m) {
print "$ARGV: $m"
}'