Colin, I'll rather propose that (simplifying the code):
# Prevent from updating if parameters already present (persistent usb key)
if ! `grep -qs 'AutomaticLoginEnable' $GDMCustomFile` ; then
if ! `grep -qs '\[daemon\]' $GDMCustomFile` ; then
printf '[daemon]' >> $GDMCustomFile
fi
sed -i "s/\[daemon\]/\[daemon\]\n$AutologinParameters/" $GDMCustomFile
fi
With that, we handle every cases:
- no GDMCustomFile, create the autologin part with [daemon]
- GDMCustomFile already exists with [daemon] section but without the autologin part (case of ubutu derivatives): add it
- GDMCustomFile exists without [daemon] section: add all the autologin stuff and the section (don't know if that can happen with current GDM implementation, but it'll surely later)
- GDMCustomFile exists with [daemon] section and autologin stuff in place (case of persistent usb key): don't do anything
And we get our \n interpreted by sed :)
This new proposal is in my linked branch.
Colin, I'll rather propose that (simplifying the code):
# Prevent from updating if parameters already present (persistent usb key) Enable' $GDMCustomFile` ; then ]/\[daemon\ ]\n$AutologinPa rameters/ " $GDMCustomFile
if ! `grep -qs 'AutomaticLogin
if ! `grep -qs '\[daemon\]' $GDMCustomFile` ; then
printf '[daemon]' >> $GDMCustomFile
fi
sed -i "s/\[daemon\
fi
With that, we handle every cases:
- no GDMCustomFile, create the autologin part with [daemon]
- GDMCustomFile already exists with [daemon] section but without the autologin part (case of ubutu derivatives): add it
- GDMCustomFile exists without [daemon] section: add all the autologin stuff and the section (don't know if that can happen with current GDM implementation, but it'll surely later)
- GDMCustomFile exists with [daemon] section and autologin stuff in place (case of persistent usb key): don't do anything
And we get our \n interpreted by sed :)
This new proposal is in my linked branch.