diff options
author | Sam Chudnick <sam@chudnick.com> | 2022-04-15 21:08:34 -0400 |
---|---|---|
committer | Sam Chudnick <sam@chudnick.com> | 2022-04-15 21:08:34 -0400 |
commit | 85c561f9a32f8f2b9ddf34e7d60ef4b7bf0d3680 (patch) | |
tree | 637c319270201555d66f9bf1cbcc63d893405e69 /automap |
inital commit - various scripts
Diffstat (limited to 'automap')
-rwxr-xr-x | automap | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Configures a FreeIPA client to use a provided location for automount | ||
4 | |||
5 | help() { | ||
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 | |||
14 | opts=$(getopt -o "a,h,l:" -l "append,help,location:" -- "$@") | ||
15 | eval set -- "$opts" | ||
16 | location= | ||
17 | append=0 | ||
18 | while true | ||
19 | do | ||
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 | ||
26 | done | ||
27 | [ -z "$location" ] && help | ||
28 | |||
29 | domain="$(grep "domain =" /etc/ipa/default.conf | cut -d '=' -f 2 | tr -d ' ')" | ||
30 | dc1="$(echo $domain | cut -d '.' -f 1)" | ||
31 | dc2="$(echo $domain | cut -d '.' -f 2)" | ||
32 | mstr="+ldap:automountmapname=auto.master,cn=$location,cn=automount,dc=$dc1,dc=$dc2" | ||
33 | drct="/-\tldap:automountmapname=auto.direct,cn=$location,cn=automount,dc=$dc1,dc=$dc2" | ||
34 | str="$mstr\n$drct" | ||
35 | [ $append -eq 0 ] && echo $str > /etc/auto.master || echo $str >> /etc/auto.master | ||
36 | |||
37 | systemctl restart autofs | ||