Blame uninstall.sh

076e023
#!/bin/bash
076e023
076e023
set -e
076e023
# set -x
076e023
076e023
HOST=${HOST:-/host}
076e023
076e023
mkdir -p "$HOST/var/log/sssd/uninstall"
076e023
mv /var/log /var/log-aside && ln -s "$HOST/var/log/sssd/uninstall" /var/log
076e023
076e023
export _SYSTEMCTL_LITE_LOGFILE="$HOST/var/log/sssd/uninstall/systemctl.log"
076e023
touch $_SYSTEMCTL_LITE_LOGFILE
076e023
076e023
echo "Initializing configuration context from host ..."
076e023
( cd "$HOST" && while read f ; do
076e023
	if [ -e "$f" ] ; then
076e023
		cp --parents -rp -t / "$f"
076e023
	fi
076e023
done ) < /etc/host-data-list
076e023
076e023
mkdir -p /etc/sssd/systemctl-lite-enabled
076e023
rm -rf /etc/systemctl-lite-enabled
076e023
ln -s /etc/sssd/systemctl-lite-enabled /etc/systemctl-lite-enabled
076e023
076e023
if [ -n "$1" ] ; then
076e023
	if [ "$1" == 'realm' -o "$1" == "/sbin/realm" -o "$1" == "/usr/sbin/realm" ] ; then
076e023
		COMMAND="$1 $2"
076e023
		shift ; shift
076e023
		params=("--install=/")
076e023
		systemctl start dbus.service
076e023
	elif [ "${1#-}" == "$1" ] ; then
076e023
		COMMAND="$1"
076e023
		shift
076e023
	fi
076e023
fi
076e023
076e023
if [ -z "$COMMAND" ] ; then
076e023
	if [ -f "$HOST/etc/$NAME/realm-join-options" ] ; then
076e023
		COMMAND='realm leave'
076e023
		params=("--install=/")
076e023
	else
076e023
		COMMAND='ipa-client-install -U --uninstall'
076e023
	fi
076e023
fi
076e023
076e023
$COMMAND "${params[@]}"
076e023
076e023
rm -rf /var/lib/sss/{mc,pipes}/*
076e023
076e023
echo "Copying new configuration to host ..."
076e023
while read f ; do
076e023
	( cd "$HOST" && find "$f" ) | while read g ; do
076e023
		if ! [ -e "/$g" ] ; then
076e023
			echo "Removing /$g"
076e023
			rm -rf "$HOST/$g"
076e023
		fi
076e023
	done
076e023
	if [ -e "$f" ] ; then
076e023
		cp --parents -rp -t "$HOST" "$f"
076e023
	fi
076e023
done < /etc/host-data-list
076e023