chiark / gitweb /
bin/disorder-switch-config, bin/disorder-propagate-autoplay: New sripts.
[profile] / bin / disorder-switch-config
CommitLineData
8f3f3f67
MW
1#! /bin/sh -e
2
3prog=${0##*/}
4fail () { echo >&2 "$prog: $1"; exit 2; }
5usage () { echo "usage: $prog [CONF]"; }
6
7bogus=nil
8while getopts "h" opt; do
9 case $opt in
10 h) usage; exit 0 ;;
11 *) bogus=t ;;
12 esac
13done
14shift $(( $OPTIND - 1 ))
15case $# in 0) op=query ;; 1) op=set conf=$1 ;; *) bogus=t ;; esac
16case $bogus in t) usage >&2; exit 2 ;; esac
17
18cd "$HOME/.disorder"
19case $op in
20 query)
21 if ! [ -L passwd ]; then link=bogus
22 else link=$(readlink passwd)
23 fi
24 case $link in
25 passwd.*) conf=${link#passwd.} ;;
26 *) fail "\`~/.disorder/passwd' not a link to \`passwd.CONF'" ;;
27 esac
28 echo "$conf"
29 ;;
30 set)
31 if ! [ -f "passwd.$conf" ]; then fail "no config \`passwd.$conf'"; fi
32 ln -sf "passwd.$conf" passwd
33 ;;
34esac