qemu-boot.sh: Come code cleanup

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2019-09-15 10:05:03 +00:00
commit 0023d7fdfb

View file

@ -3,7 +3,7 @@
goodbye() goodbye()
{ {
: :
# rm -f $tmp_files rm -f $tmp_files
} }
usage() usage()
@ -43,20 +43,25 @@ do_sudo()
log running $@ log running $@
eval "$@" eval "$@"
return $? return $?
else
log running sudo $@
#sudo -p "Password for $myname:" $@
eval sudo "$@"
return $?
fi fi
log running sudo $@
#sudo -p "Password for $myname:" $@
eval sudo "$@"
return $?
} }
ldap_search() ldap_search()
{ {
local ldap_server=ldap.lcl local ldap_server=ldap.lcl
local binddn=cn=ldapadm,dc=jannet,dc=de local binddn=cn=ldapadm,dc=jannet,dc=de
local password_file=$HOME/.feedfs-ldap/passwords/$binddn@$ldap_server local password_files="$HOME/.feedfs-ldap/passwords/$binddn@$ldap_server $HOME/.ldap.secret"
[ -r "$password_file" ] || fatal "Password file $password_file doesn't exist" local p password_file
for p in $password_files; do
[ -r "$p" ] || continue
password_file=$p
break
done
[ "$password_file" ] || fatal "None of the LDAP password files $password_files exists"
ldapsearch -y $password_file -xZ -h $ldap_server -D $binddn -b $base,ou=networks,dc=jannet,dc=de $@ ldapsearch -y $password_file -xZ -h $ldap_server -D $binddn -b $base,ou=networks,dc=jannet,dc=de $@
} }
@ -75,8 +80,8 @@ boot_net()
macaddr=",macaddr=$mac" macaddr=",macaddr=$mac"
} }
ps aux | grep -v grep | grep -q dhcpd || /etc/init.d/dhcpd start systemctl try-start dhcpd-priv.lcl
ps aux | grep -v grep | grep -q nfsd || /etc/init.d/nfsserver start systemctl try-start nfsserver
[ "$nic_model" ] || nic_model=",model=e1000" [ "$nic_model" ] || nic_model=",model=e1000"
# need this for net access, would be nicer if it didn't run as root # need this for net access, would be nicer if it didn't run as root
@ -107,7 +112,6 @@ boot_image()
test -r "$boot_image" || fatal "inaccessible boot image \"$boot_image\"" test -r "$boot_image" || fatal "inaccessible boot image \"$boot_image\""
#-net bridge,br=$bridge \ #-net bridge,br=$bridge \
#-net nic,vlan=1$nic_model,macaddr=00:02:36:22:13:6c \ #-net nic,vlan=1$nic_model,macaddr=00:02:36:22:13:6c \
#-net tap,ifname=tap1,vlan=1,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \ #-net tap,ifname=tap1,vlan=1,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \
#set -x #set -x
@ -120,12 +124,9 @@ boot_image()
boot() boot()
{ {
tmpdir=`mktemp -d /tmp/$myname""_XXXXXX` tmpdir=`mktemp -d /tmp/$myname-XXXXXX`
( ln -s $exe $tmpdir/qemu-ifup
cd $tmpdir ln -s $exe $tmpdir/qemu-ifdown
ln -s $exe qemu-ifup
ln -s $exe qemu-ifdown
)
#do_sudo /sbin/modprobe kvm-intel #do_sudo /sbin/modprobe kvm-intel
tmp_files="$tmp_files $tmpdir" tmp_files="$tmp_files $tmpdir"
@ -225,4 +226,3 @@ qemu-boot.sh) # legacy
echo called as unknown executable name $0 echo called as unknown executable name $0
;; ;;
esac esac