#!/bin/bash
. /var/install/include/eislib
doit='false'
netbin='/usr/bin/net'
sidfile='/root/MACHINE.SID'
case $# in
0)
interactive='true'
;;
1)
if [ "$1" = "noninteractive" ]
then
interactive='false'
doit='true'
fi
;;
*)
echo "usage: /var/install/bin/samba-save-sid" >&2
echo " or: /var/install/bin/samba-save-sid noninteractive" >&2
exit 1
;;
esac
if [ "$interactive" = "true" ]
then
clrhome
mecho --info "Save Samba SID to $sidfile"
echo
if /var/install/bin/ask "Do you really want to save Samba SID to $sidfile" "yes"
then
doit='true'
fi
fi
echo
if [ "$doit" = "true" ]
then
. /etc/config.d/cui-samba
sid=`$netbin getlocalsid $SAMBA_WORKGROUP 2>/dev/null | cut -d' ' -f6`
if [ -n "$sid" ]
then
echo "$sid" >"$sidfile"
if [ $? -eq 0 ]
then
mecho --info "Samba SID"
echo
echo "$sid"
echo
mecho --info "saved to $sidfile."
else
mecho --error "Could not save Samba SID"
echo
echo "$sid"
echo
mecho --error "to $sidfile!"
fi
else
mecho --error "Could not fetch Samba SID for Domain $SAMBA_WORKGROUP!"
mecho --error "Is Samba configured as PDC?"
fi
else
echo "Samba SID not saved."
fi
if [ "$interactive" = "true" ]
then
anykey
fi