startup cleanup even after reordering

This commit is contained in:
nativemad 2018-10-23 18:08:14 +02:00
parent f10d0e51bb
commit 3581d8ec80
1 changed files with 4 additions and 4 deletions

8
nlvmi
View File

@ -150,7 +150,7 @@ function vmstart {
#prepare tmpfile
TMPF=/home/nlvmi/start${array[32]}-${array[1]}.tmp
rm /home/nlvmi/start*-${array[1]}.tmp &>/dev/null
touch $TMPF && chmod 660 $TMPF
touch $TMPF && chmod 660 $TMPF && chown nlvmi: $TMPF
#add user if necessary
echo "if ! \`id -u ${array[2]} &>/dev/null\`; then useradd ${array[2]} -d /run/nlvmi -g nlvmi -M -s /bin/false -G kvm; fi" >>$TMPF
#chown mon and pid files
@ -188,10 +188,10 @@ function vmstart {
if [ ! -z "${array[35]}" ]; then
echo "chmod g+w $RUNDIRECTORY/${array[1]}.mon" >>$TMPF
echo "chmod g+r $RUNDIRECTORY/${array[1]}.pid" >>$TMPF
openssl dgst -sha512 -sign "/etc/nlvmi/nlvmi_priv.key" -out /home/nlvmi/${array[1]}.tmp.sha512 $TMPF
TMPFR="/home/nlvmi/rstart{array[32]}-${array[1]}.tmp"
openssl dgst -sha512 -sign "/etc/nlvmi/nlvmi_priv.key" -out /home/nlvmi/start${array[32]}-${array[1]}.tmp.sha512 $TMPF
TMPFR="/home/nlvmi/rstart${array[32]}-${array[1]}.tmp"
mv $TMPF $TMPFR
su nlvmi -c "ssh ${array[35]} \"rm /home/nlvmi/start*-${array[1]}.tmp\""
su nlvmi -c "ssh ${array[35]} \"rm /home/nlvmi/start*-${array[1]}.tmp*\""
mv $TMPFR $TMPF
su nlvmi -c "scp $TMPF* ${array[35]}:/home/nlvmi/"
su nlvmi -c "ssh ${array[35]} \"/usr/bin/nlvmi remote $TMPF run\""