#!/bin/sh # # Configures a FreeIPA client to use a provided location for automount help() { echo "usage: automap [--append] --location location" echo "-a, --append:\tappend location (default is to replace existing locations)" echo "-l, --location:\tname of automount location" exit 1 } [ $(id -u) -ne 0 ] && echo "error: must be run as root" && exit 1 opts=$(getopt -o "a,h,l:" -l "append,help,location:" -- "$@") eval set -- "$opts" location= append=0 while true do case "$1" in '-a' | '--append') append=1 shift; continue ;; '-l' | '--location') location="$2" shift 2; continue ;; '-h' | '--help') help ;; '--') shift; break ;; esac done [ -z "$location" ] && help domain="$(grep "domain =" /etc/ipa/default.conf | cut -d '=' -f 2 | tr -d ' ')" dc1="$(echo $domain | cut -d '.' -f 1)" dc2="$(echo $domain | cut -d '.' -f 2)" mstr="+ldap:automountmapname=auto.master,cn=$location,cn=automount,dc=$dc1,dc=$dc2" drct="/-\tldap:automountmapname=auto.direct,cn=$location,cn=automount,dc=$dc1,dc=$dc2" str="$mstr\n$drct" [ $append -eq 0 ] && echo $str > /etc/auto.master || echo $str >> /etc/auto.master systemctl restart autofs