mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 16:05:21 +01:00
Advanced settings: rework username/password logic
- Also change group name. - Outsource changes to /usr/lib/userconf-pi/userconf if present
This commit is contained in:
parent
2f4fe2f35a
commit
34460f84b8
1 changed files with 25 additions and 18 deletions
|
@ -618,10 +618,9 @@ Popup {
|
||||||
addCloudInit(" groups: users,adm,dialout,audio,netdev,video,plugdev,cdrom,games,input,gpio,spi,i2c,render,sudo")
|
addCloudInit(" groups: users,adm,dialout,audio,netdev,video,plugdev,cdrom,games,input,gpio,spi,i2c,render,sudo")
|
||||||
addCloudInit(" shell: /bin/bash")
|
addCloudInit(" shell: /bin/bash")
|
||||||
|
|
||||||
|
var cryptedPassword;
|
||||||
if (chkSetUser.checked) {
|
if (chkSetUser.checked) {
|
||||||
var cryptedPassword = fieldUserPassword.alreadyCrypted ? fieldUserPassword.text : imageWriter.crypt(fieldUserPassword.text)
|
cryptedPassword = fieldUserPassword.alreadyCrypted ? fieldUserPassword.text : imageWriter.crypt(fieldUserPassword.text)
|
||||||
addFirstRun("echo \"$FIRSTUSER:\""+escapeshellarg(cryptedPassword)+" | chpasswd -e")
|
|
||||||
|
|
||||||
addCloudInit(" lock_passwd: false")
|
addCloudInit(" lock_passwd: false")
|
||||||
addCloudInit(" passwd: "+cryptedPassword)
|
addCloudInit(" passwd: "+cryptedPassword)
|
||||||
}
|
}
|
||||||
|
@ -654,10 +653,16 @@ Popup {
|
||||||
addCloudInit("ssh_pwauth: true")
|
addCloudInit("ssh_pwauth: true")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chkSetUser.checked) {
|
||||||
/* Rename first ("pi") user if a different desired username was specified */
|
/* Rename first ("pi") user if a different desired username was specified */
|
||||||
|
addFirstRun("if [ -f /usr/lib/userconf-pi/userconf ]; then")
|
||||||
|
addFirstRun(" /usr/lib/userconf-pi/userconf "+escapeshellarg(fieldUserName.text)+" "+escapeshellarg(cryptedPassword))
|
||||||
|
addFirstRun("else")
|
||||||
|
addFirstRun(" echo \"$FIRSTUSER:\""+escapeshellarg(cryptedPassword)+" | chpasswd -e")
|
||||||
addFirstRun(" if [ \"$FIRSTUSER\" != \""+fieldUserName.text+"\" ]; then")
|
addFirstRun(" if [ \"$FIRSTUSER\" != \""+fieldUserName.text+"\" ]; then")
|
||||||
addFirstRun(" usermod -l \""+fieldUserName.text+"\" \"$FIRSTUSER\"")
|
addFirstRun(" usermod -l \""+fieldUserName.text+"\" \"$FIRSTUSER\"")
|
||||||
addFirstRun(" usermod -m -d \"/home/"+fieldUserName.text+"\" \""+fieldUserName.text+"\"")
|
addFirstRun(" usermod -m -d \"/home/"+fieldUserName.text+"\" \""+fieldUserName.text+"\"")
|
||||||
|
addFirstRun(" groupmod -n \""+fieldUserName.text+"\" \"$FIRSTUSER\"")
|
||||||
addFirstRun(" if grep -q \"^autologin-user=\" /etc/lightdm/lightdm.conf ; then")
|
addFirstRun(" if grep -q \"^autologin-user=\" /etc/lightdm/lightdm.conf ; then")
|
||||||
addFirstRun(" sed /etc/lightdm/lightdm.conf -i -e \"s/^autologin-user=.*/autologin-user="+fieldUserName.text+"/\"")
|
addFirstRun(" sed /etc/lightdm/lightdm.conf -i -e \"s/^autologin-user=.*/autologin-user="+fieldUserName.text+"/\"")
|
||||||
addFirstRun(" fi")
|
addFirstRun(" fi")
|
||||||
|
@ -668,6 +673,8 @@ Popup {
|
||||||
addFirstRun(" sed -i \"s/^$FIRSTUSER /"+fieldUserName.text+" /\" /etc/sudoers.d/010_pi-nopasswd")
|
addFirstRun(" sed -i \"s/^$FIRSTUSER /"+fieldUserName.text+" /\" /etc/sudoers.d/010_pi-nopasswd")
|
||||||
addFirstRun(" fi")
|
addFirstRun(" fi")
|
||||||
addFirstRun(" fi")
|
addFirstRun(" fi")
|
||||||
|
addFirstRun("fi")
|
||||||
|
}
|
||||||
|
|
||||||
if (chkSSH.checked) {
|
if (chkSSH.checked) {
|
||||||
addFirstRun("systemctl enable ssh")
|
addFirstRun("systemctl enable ssh")
|
||||||
|
@ -716,7 +723,7 @@ Popup {
|
||||||
addCloudInitRun("sed -i 's/^\s*REGDOMAIN=\S*/REGDOMAIN="+fieldWifiCountry.editText+"/' /etc/default/crda || true")
|
addCloudInitRun("sed -i 's/^\s*REGDOMAIN=\S*/REGDOMAIN="+fieldWifiCountry.editText+"/' /etc/default/crda || true")
|
||||||
}
|
}
|
||||||
if (chkLocale.checked) {
|
if (chkLocale.checked) {
|
||||||
if (chkSkipFirstUse) {
|
if (chkSkipFirstUse.checked) {
|
||||||
addFirstRun("rm -f /etc/xdg/autostart/piwiz.desktop")
|
addFirstRun("rm -f /etc/xdg/autostart/piwiz.desktop")
|
||||||
addCloudInitRun("rm -f /etc/xdg/autostart/piwiz.desktop")
|
addCloudInitRun("rm -f /etc/xdg/autostart/piwiz.desktop")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue