summaryrefslogtreecommitdiff
path: root/automap
diff options
context:
space:
mode:
authorSam Chudnick <sam@chudnick.com>2022-04-15 21:08:34 -0400
committerSam Chudnick <sam@chudnick.com>2022-04-15 21:08:34 -0400
commit85c561f9a32f8f2b9ddf34e7d60ef4b7bf0d3680 (patch)
tree637c319270201555d66f9bf1cbcc63d893405e69 /automap
inital commit - various scripts
Diffstat (limited to 'automap')
-rwxr-xr-xautomap37
1 files changed, 37 insertions, 0 deletions
diff --git a/automap b/automap
new file mode 100755
index 0000000..b92b0b9
--- /dev/null
+++ b/automap
@@ -0,0 +1,37 @@
1#!/bin/sh
2#
3# Configures a FreeIPA client to use a provided location for automount
4
5help() {
6 echo "usage: automap [--append] --location location"
7 echo "-a, --append:\tappend location (default is to replace existing locations)"
8 echo "-l, --location:\tname of automount location"
9 exit 1
10}
11
12[ $(id -u) -ne 0 ] && echo "error: must be run as root" && exit 1
13
14opts=$(getopt -o "a,h,l:" -l "append,help,location:" -- "$@")
15eval set -- "$opts"
16location=
17append=0
18while true
19do
20 case "$1" in
21 '-a' | '--append') append=1 shift; continue ;;
22 '-l' | '--location') location="$2" shift 2; continue ;;
23 '-h' | '--help') help ;;
24 '--') shift; break ;;
25 esac
26done
27[ -z "$location" ] && help
28
29domain="$(grep "domain =" /etc/ipa/default.conf | cut -d '=' -f 2 | tr -d ' ')"
30dc1="$(echo $domain | cut -d '.' -f 1)"
31dc2="$(echo $domain | cut -d '.' -f 2)"
32mstr="+ldap:automountmapname=auto.master,cn=$location,cn=automount,dc=$dc1,dc=$dc2"
33drct="/-\tldap:automountmapname=auto.direct,cn=$location,cn=automount,dc=$dc1,dc=$dc2"
34str="$mstr\n$drct"
35[ $append -eq 0 ] && echo $str > /etc/auto.master || echo $str >> /etc/auto.master
36
37systemctl restart autofs