2021-01-17 17:43:17 +01:00
|
|
|
/*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2022-02-03 11:48:21 +01:00
|
|
|
* Copyright (C) 2021 Raspberry Pi Ltd
|
2021-01-17 17:43:17 +01:00
|
|
|
*/
|
|
|
|
|
2023-03-19 21:54:00 +01:00
|
|
|
import QtQuick 2.15
|
2021-01-17 17:43:17 +01:00
|
|
|
import QtQuick.Controls 2.2
|
2023-09-22 23:51:36 +02:00
|
|
|
import QtQuick.Layouts 1.15
|
2021-01-17 17:43:17 +01:00
|
|
|
import QtQuick.Controls.Material 2.2
|
2023-09-22 23:51:36 +02:00
|
|
|
import QtQuick.Window 2.15
|
2022-02-04 12:32:12 +01:00
|
|
|
import "qmlcomponents"
|
2021-01-17 17:43:17 +01:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
Window {
|
2021-01-17 17:43:17 +01:00
|
|
|
id: popup
|
2023-09-22 23:51:36 +02:00
|
|
|
width: cl.implicitWidth+cl.spacing
|
|
|
|
minimumWidth: width
|
|
|
|
maximumWidth: width
|
|
|
|
minimumHeight: 125
|
|
|
|
height: Math.min(750, cl.implicitHeight)
|
2023-10-16 13:09:34 +01:00
|
|
|
title: qsTr("OS Customization")
|
2023-09-22 23:51:36 +02:00
|
|
|
|
2021-01-17 17:43:17 +01:00
|
|
|
property bool initialized: false
|
2021-01-20 13:04:18 +01:00
|
|
|
property bool hasSavedSettings: false
|
2021-01-17 17:43:17 +01:00
|
|
|
property string config
|
|
|
|
property string cmdline
|
|
|
|
property string firstrun
|
2021-11-18 20:48:24 +01:00
|
|
|
property string cloudinit
|
|
|
|
property string cloudinitrun
|
|
|
|
property string cloudinitwrite
|
|
|
|
property string cloudinitnetwork
|
2021-01-17 17:43:17 +01:00
|
|
|
|
|
|
|
ColumnLayout {
|
2023-09-22 23:51:36 +02:00
|
|
|
id: cl
|
2023-09-23 19:45:17 +02:00
|
|
|
spacing: 10
|
2021-01-17 17:43:17 +01:00
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
id: popupbody
|
|
|
|
font.family: roboto.name
|
|
|
|
//Layout.maximumWidth: popup.width-30
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.leftMargin: 25
|
|
|
|
Layout.topMargin: 10
|
|
|
|
clip: true
|
2023-09-22 23:51:36 +02:00
|
|
|
//ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
2021-01-17 17:43:17 +01:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
ColumnLayout {
|
2021-01-17 17:43:17 +01:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
RowLayout {
|
2021-01-20 13:04:18 +01:00
|
|
|
Label {
|
2023-10-16 13:09:34 +01:00
|
|
|
text: qsTr("OS customization options")
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
|
|
|
ComboBox {
|
|
|
|
id: comboSaveSettings
|
|
|
|
model: {
|
|
|
|
[qsTr("for this session only"),
|
|
|
|
qsTr("to always use")]
|
|
|
|
}
|
|
|
|
Layout.minimumWidth: 250
|
|
|
|
Layout.maximumHeight: 40
|
2021-11-22 00:21:30 +01:00
|
|
|
enabled: !imageWriter.isEmbeddedMode()
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
TabBar {
|
|
|
|
id: bar
|
|
|
|
Layout.fillWidth: true
|
2021-01-17 17:43:17 +01:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
TabButton {
|
|
|
|
text: qsTr("General")
|
2023-09-23 19:45:17 +02:00
|
|
|
onClicked: {
|
|
|
|
if (chkSetUser.checked && !fieldUserPassword.length) {
|
|
|
|
fieldUserPassword.forceActiveFocus()
|
|
|
|
}
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
2023-09-22 23:51:36 +02:00
|
|
|
TabButton {
|
|
|
|
text: qsTr("Services")
|
|
|
|
}
|
|
|
|
TabButton {
|
|
|
|
text: qsTr("Options")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GroupBox {
|
|
|
|
StackLayout {
|
|
|
|
width: parent.width
|
|
|
|
currentIndex: bar.currentIndex
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
// General tab
|
|
|
|
spacing: -10
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
ImCheckBox {
|
|
|
|
id: chkHostname
|
|
|
|
text: qsTr("Set hostname:")
|
|
|
|
onCheckedChanged: {
|
|
|
|
if (checked) {
|
|
|
|
fieldHostname.forceActiveFocus()
|
|
|
|
}
|
2022-02-01 16:02:50 +01:00
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
2023-09-22 23:51:36 +02:00
|
|
|
TextField {
|
|
|
|
id: fieldHostname
|
|
|
|
enabled: chkHostname.checked
|
|
|
|
text: "raspberrypi"
|
2023-09-23 19:45:17 +02:00
|
|
|
selectByMouse: true
|
2023-09-22 23:51:36 +02:00
|
|
|
validator: RegularExpressionValidator { regularExpression: /[0-9A-Za-z][0-9A-Za-z-]{0,62}/ }
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
text : ".local"
|
|
|
|
color: chkHostname.checked ? "black" : "grey"
|
2022-01-20 17:24:25 +01:00
|
|
|
}
|
|
|
|
}
|
2023-09-22 23:51:36 +02:00
|
|
|
|
|
|
|
ImCheckBox {
|
|
|
|
id: chkSetUser
|
|
|
|
text: qsTr("Set username and password")
|
|
|
|
onCheckedChanged: {
|
|
|
|
if (!checked && chkSSH.checked && radioPasswordAuthentication.checked) {
|
|
|
|
checked = true;
|
2022-02-14 09:59:08 +01:00
|
|
|
}
|
2023-09-23 19:45:17 +02:00
|
|
|
if (checked && !fieldUserPassword.length) {
|
|
|
|
fieldUserPassword.forceActiveFocus()
|
|
|
|
}
|
2022-01-20 17:24:25 +01:00
|
|
|
}
|
|
|
|
}
|
2021-11-19 23:30:42 +01:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
ColumnLayout {
|
|
|
|
enabled: chkSetUser.checked
|
|
|
|
Layout.leftMargin: 40
|
|
|
|
spacing: -5
|
2022-01-20 17:24:25 +01:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
GridLayout {
|
|
|
|
columns: 2
|
|
|
|
columnSpacing: 10
|
|
|
|
rowSpacing: -5
|
2021-01-17 17:43:17 +01:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
Text {
|
|
|
|
text: qsTr("Username:")
|
|
|
|
color: parent.enabled ? (fieldUserName.indicateError ? "red" : "black") : "grey"
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: fieldUserName
|
|
|
|
text: "pi"
|
|
|
|
Layout.minimumWidth: 200
|
2023-09-23 19:45:17 +02:00
|
|
|
selectByMouse: true
|
2023-09-22 23:51:36 +02:00
|
|
|
property bool indicateError: false
|
|
|
|
|
|
|
|
onTextEdited: {
|
|
|
|
indicateError = false
|
|
|
|
}
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
Text {
|
|
|
|
text: qsTr("Password:")
|
|
|
|
color: parent.enabled ? (fieldUserPassword.indicateError ? "red" : "black") : "grey"
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: fieldUserPassword
|
|
|
|
echoMode: TextInput.Password
|
|
|
|
Layout.minimumWidth: 200
|
2023-09-23 19:45:17 +02:00
|
|
|
selectByMouse: true
|
2023-09-22 23:51:36 +02:00
|
|
|
property bool alreadyCrypted: false
|
|
|
|
property bool indicateError: false
|
|
|
|
|
|
|
|
onTextEdited: {
|
|
|
|
if (alreadyCrypted) {
|
|
|
|
/* User is trying to edit saved
|
|
|
|
(crypted) password, clear field */
|
|
|
|
alreadyCrypted = false
|
|
|
|
clear()
|
|
|
|
}
|
|
|
|
if (indicateError) {
|
|
|
|
indicateError = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-20 17:24:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
ImCheckBox {
|
|
|
|
id: chkWifi
|
|
|
|
text: qsTr("Configure wireless LAN")
|
|
|
|
onCheckedChanged: {
|
|
|
|
if (checked) {
|
|
|
|
if (!fieldWifiSSID.length) {
|
|
|
|
fieldWifiSSID.forceActiveFocus()
|
|
|
|
} else if (!fieldWifiPassword.length) {
|
|
|
|
fieldWifiPassword.forceActiveFocus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
2023-09-22 23:51:36 +02:00
|
|
|
GridLayout {
|
|
|
|
enabled: chkWifi.checked
|
|
|
|
Layout.leftMargin: 40
|
|
|
|
columns: 2
|
|
|
|
columnSpacing: 10
|
|
|
|
rowSpacing: -5
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: qsTr("SSID:")
|
|
|
|
color: parent.enabled ? (fieldWifiSSID.indicateError ? "red" : "black") : "grey"
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: fieldWifiSSID
|
|
|
|
Layout.minimumWidth: 200
|
2023-09-23 19:45:17 +02:00
|
|
|
selectByMouse: true
|
2023-09-22 23:51:36 +02:00
|
|
|
property bool indicateError: false
|
|
|
|
onTextEdited: {
|
|
|
|
indicateError = false
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
2023-09-22 23:51:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: qsTr("Password:")
|
|
|
|
color: parent.enabled ? (fieldWifiPassword.indicateError ? "red" : "black") : "grey"
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: fieldWifiPassword
|
|
|
|
Layout.minimumWidth: 200
|
2023-09-23 19:45:17 +02:00
|
|
|
selectByMouse: true
|
2023-09-22 23:51:36 +02:00
|
|
|
echoMode: chkShowPassword.checked ? TextInput.Normal : TextInput.Password
|
|
|
|
property bool indicateError: false
|
|
|
|
onTextEdited: {
|
2021-03-27 11:04:13 +01:00
|
|
|
indicateError = false
|
|
|
|
}
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
|
2023-09-23 19:45:17 +02:00
|
|
|
RowLayout {
|
2023-09-22 23:51:36 +02:00
|
|
|
Layout.columnSpan: 2
|
2023-09-23 19:45:17 +02:00
|
|
|
|
|
|
|
ImCheckBox {
|
|
|
|
id: chkShowPassword
|
|
|
|
text: qsTr("Show password")
|
|
|
|
checked: true
|
|
|
|
}
|
|
|
|
ImCheckBox {
|
|
|
|
id: chkWifiSSIDHidden
|
|
|
|
Layout.columnSpan: 2
|
|
|
|
text: qsTr("Hidden SSID")
|
|
|
|
checked: false
|
|
|
|
}
|
2023-09-22 23:51:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: qsTr("Wireless LAN country:")
|
|
|
|
color: parent.enabled ? "black" : "grey"
|
|
|
|
}
|
|
|
|
ComboBox {
|
|
|
|
id: fieldWifiCountry
|
|
|
|
editable: true
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
ImCheckBox {
|
|
|
|
id: chkLocale
|
|
|
|
text: qsTr("Set locale settings")
|
|
|
|
}
|
|
|
|
GridLayout {
|
|
|
|
enabled: chkLocale.checked
|
|
|
|
Layout.leftMargin: 40
|
|
|
|
columns: 2
|
|
|
|
columnSpacing: 10
|
|
|
|
rowSpacing: -5
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: qsTr("Time zone:")
|
|
|
|
color: parent.enabled ? "black" : "grey"
|
|
|
|
}
|
|
|
|
ComboBox {
|
|
|
|
id: fieldTimezone
|
|
|
|
editable: true
|
|
|
|
Layout.minimumWidth: 200
|
|
|
|
}
|
2022-01-09 21:32:25 +00:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
Text {
|
|
|
|
text: qsTr("Keyboard layout:")
|
|
|
|
color: parent.enabled ? "black" : "grey"
|
|
|
|
}
|
|
|
|
ComboBox {
|
|
|
|
id: fieldKeyboardLayout
|
|
|
|
editable: true
|
|
|
|
Layout.minimumWidth: 200
|
|
|
|
}
|
2021-04-11 14:09:28 +02:00
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
ColumnLayout {
|
|
|
|
// Remote access tab
|
|
|
|
spacing: -10
|
|
|
|
|
|
|
|
ImCheckBox {
|
|
|
|
id: chkSSH
|
|
|
|
text: qsTr("Enable SSH")
|
|
|
|
onCheckedChanged: {
|
|
|
|
if (checked) {
|
|
|
|
if (!radioPasswordAuthentication.checked && !radioPubKeyAuthentication.checked) {
|
|
|
|
radioPasswordAuthentication.checked = true
|
|
|
|
}
|
|
|
|
if (radioPasswordAuthentication.checked) {
|
|
|
|
chkSetUser.checked = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ColumnLayout {
|
|
|
|
enabled: chkSSH.checked
|
|
|
|
Layout.leftMargin: 40
|
|
|
|
spacing: -10
|
|
|
|
|
|
|
|
ImRadioButton {
|
|
|
|
id: radioPasswordAuthentication
|
|
|
|
text: qsTr("Use password authentication")
|
|
|
|
onCheckedChanged: {
|
|
|
|
if (checked) {
|
|
|
|
chkSetUser.checked = true
|
|
|
|
//fieldUserPassword.forceActiveFocus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImRadioButton {
|
|
|
|
id: radioPubKeyAuthentication
|
|
|
|
text: qsTr("Allow public-key authentication only")
|
|
|
|
onCheckedChanged: {
|
|
|
|
if (checked) {
|
|
|
|
if (chkSetUser.checked && fieldUserName.text == "pi" && fieldUserPassword.text.length == 0) {
|
|
|
|
chkSetUser.checked = false
|
|
|
|
}
|
|
|
|
fieldPublicKey.forceActiveFocus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GridLayout {
|
|
|
|
Layout.leftMargin: 40
|
|
|
|
columns: 1
|
|
|
|
columnSpacing: 10
|
|
|
|
rowSpacing: -5
|
|
|
|
enabled: radioPubKeyAuthentication.checked
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: qsTr("Set authorized_keys for '%1':").arg(fieldUserName.text)
|
|
|
|
color: parent.enabled ? "black" : "grey"
|
|
|
|
textFormat: Text.PlainText
|
|
|
|
}
|
|
|
|
TextArea {
|
|
|
|
id: fieldPublicKey
|
|
|
|
wrapMode: TextEdit.WrapAnywhere
|
|
|
|
Layout.minimumWidth: 400
|
2023-09-23 19:45:17 +02:00
|
|
|
selectByMouse: true
|
2023-09-22 23:51:36 +02:00
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
ImButton {
|
|
|
|
text: qsTr("RUN SSH-KEYGEN")
|
|
|
|
enabled: imageWriter.hasSshKeyGen() && !imageWriter.hasPubKey()
|
|
|
|
onClicked: {
|
|
|
|
enabled = false
|
|
|
|
imageWriter.generatePubKey()
|
|
|
|
fieldPublicKey.text = imageWriter.getDefaultPubKey()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
ColumnLayout {
|
|
|
|
// Options tab
|
|
|
|
spacing: -10
|
2021-01-17 17:43:17 +01:00
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
ImCheckBox {
|
|
|
|
id: chkBeep
|
|
|
|
text: qsTr("Play sound when finished")
|
|
|
|
}
|
|
|
|
ImCheckBox {
|
|
|
|
id: chkEject
|
|
|
|
text: qsTr("Eject media when finished")
|
|
|
|
}
|
|
|
|
ImCheckBox {
|
|
|
|
id: chkTelemtry
|
|
|
|
text: qsTr("Enable telemetry")
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Layout.alignment: Qt.AlignCenter | Qt.AlignBottom
|
|
|
|
Layout.bottomMargin: 10
|
|
|
|
spacing: 20
|
|
|
|
|
2022-02-04 12:32:12 +01:00
|
|
|
ImButton {
|
2021-01-17 17:43:17 +01:00
|
|
|
text: qsTr("SAVE")
|
|
|
|
onClicked: {
|
2022-02-01 16:02:50 +01:00
|
|
|
if (chkSetUser.checked && fieldUserPassword.text.length == 0)
|
2021-01-17 17:43:17 +01:00
|
|
|
{
|
2021-03-27 11:04:13 +01:00
|
|
|
fieldUserPassword.indicateError = true
|
2021-01-17 17:43:17 +01:00
|
|
|
fieldUserPassword.forceActiveFocus()
|
2023-09-22 23:51:36 +02:00
|
|
|
bar.currentIndex = 0
|
2021-01-17 17:43:17 +01:00
|
|
|
return
|
|
|
|
}
|
2022-02-01 16:02:50 +01:00
|
|
|
if (chkSetUser.checked && fieldUserName.text.length == 0)
|
2021-11-19 23:30:42 +01:00
|
|
|
{
|
|
|
|
fieldUserName.indicateError = true
|
|
|
|
fieldUserName.forceActiveFocus()
|
2023-09-22 23:51:36 +02:00
|
|
|
bar.currentIndex = 0
|
2021-11-19 23:30:42 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-11 14:09:28 +02:00
|
|
|
if (chkWifi.checked)
|
|
|
|
{
|
|
|
|
if (fieldWifiPassword.text.length < 8 || fieldWifiPassword.text.length > 64)
|
|
|
|
{
|
|
|
|
fieldWifiPassword.indicateError = true
|
|
|
|
fieldWifiPassword.forceActiveFocus()
|
|
|
|
}
|
|
|
|
if (fieldWifiSSID.text.length == 0)
|
|
|
|
{
|
|
|
|
fieldWifiSSID.indicateError = true
|
|
|
|
fieldWifiSSID.forceActiveFocus()
|
|
|
|
}
|
|
|
|
if (fieldWifiSSID.indicateError || fieldWifiPassword.indicateError)
|
|
|
|
{
|
2023-09-22 23:51:36 +02:00
|
|
|
bar.currentIndex = 0
|
2021-04-11 14:09:28 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
|
|
|
|
applySettings()
|
2021-01-20 13:04:18 +01:00
|
|
|
saveSettings()
|
2021-01-17 17:43:17 +01:00
|
|
|
popup.close()
|
|
|
|
}
|
2022-02-04 12:32:12 +01:00
|
|
|
Material.foreground: activeFocus ? "#d1dcfb" : "#ffffff"
|
2021-01-17 17:43:17 +01:00
|
|
|
Material.background: "#c51a4a"
|
|
|
|
}
|
|
|
|
|
|
|
|
Text { text: " " }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-20 13:04:18 +01:00
|
|
|
function initialize() {
|
|
|
|
chkBeep.checked = imageWriter.getBoolSetting("beep")
|
|
|
|
chkTelemtry.checked = imageWriter.getBoolSetting("telemetry")
|
|
|
|
chkEject.checked = imageWriter.getBoolSetting("eject")
|
|
|
|
var settings = imageWriter.getSavedCustomizationSettings()
|
|
|
|
fieldTimezone.model = imageWriter.getTimezoneList()
|
|
|
|
fieldPublicKey.text = imageWriter.getDefaultPubKey()
|
|
|
|
fieldWifiCountry.model = imageWriter.getCountryList()
|
2021-11-22 00:21:30 +01:00
|
|
|
fieldKeyboardLayout.model = imageWriter.getKeymapLayoutList()
|
2021-01-20 13:04:18 +01:00
|
|
|
|
|
|
|
if (Object.keys(settings).length) {
|
|
|
|
comboSaveSettings.currentIndex = 1
|
|
|
|
hasSavedSettings = true
|
|
|
|
}
|
|
|
|
if ('hostname' in settings) {
|
|
|
|
fieldHostname.text = settings.hostname
|
|
|
|
chkHostname.checked = true
|
|
|
|
}
|
|
|
|
if ('sshUserPassword' in settings) {
|
|
|
|
fieldUserPassword.text = settings.sshUserPassword
|
|
|
|
fieldUserPassword.alreadyCrypted = true
|
2022-01-20 17:24:25 +01:00
|
|
|
chkSetUser.checked = true
|
2022-02-01 16:02:50 +01:00
|
|
|
/* Older imager versions did not have a sshEnabled setting.
|
|
|
|
Assume it is true if it does not exists and sshUserPassword is set */
|
2022-02-03 18:57:41 +01:00
|
|
|
if (!('sshEnabled' in settings) || settings.sshEnabled === "true" || settings.sshEnabled === true) {
|
2022-02-01 16:02:50 +01:00
|
|
|
chkSSH.checked = true
|
|
|
|
radioPasswordAuthentication.checked = true
|
|
|
|
}
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
2022-07-26 23:20:42 +02:00
|
|
|
if ('sshAuthorizedKeys' in settings) {
|
|
|
|
fieldPublicKey.text = settings.sshAuthorizedKeys
|
|
|
|
radioPubKeyAuthentication.checked = true
|
|
|
|
chkSSH.checked = true
|
|
|
|
}
|
|
|
|
|
2021-11-19 23:30:42 +01:00
|
|
|
if ('sshUserName' in settings) {
|
|
|
|
fieldUserName.text = settings.sshUserName
|
2022-01-20 17:24:25 +01:00
|
|
|
chkSetUser.checked = true
|
2022-11-15 01:10:46 +01:00
|
|
|
} else {
|
|
|
|
fieldUserName.text = imageWriter.getCurrentUser()
|
2021-11-19 23:30:42 +01:00
|
|
|
}
|
2022-11-15 01:10:46 +01:00
|
|
|
|
2021-01-20 13:04:18 +01:00
|
|
|
if ('wifiSSID' in settings) {
|
|
|
|
fieldWifiSSID.text = settings.wifiSSID
|
2022-02-03 18:57:41 +01:00
|
|
|
if ('wifiSSIDHidden' in settings && settings.wifiSSIDHidden) {
|
|
|
|
chkWifiSSIDHidden.checked = true
|
|
|
|
}
|
2021-01-20 13:04:18 +01:00
|
|
|
chkShowPassword.checked = false
|
|
|
|
fieldWifiPassword.text = settings.wifiPassword
|
|
|
|
fieldWifiCountry.currentIndex = fieldWifiCountry.find(settings.wifiCountry)
|
|
|
|
if (fieldWifiCountry.currentIndex == -1) {
|
|
|
|
fieldWifiCountry.editText = settings.wifiCountry
|
|
|
|
}
|
|
|
|
chkWifi.checked = true
|
|
|
|
} else {
|
2021-01-17 17:43:17 +01:00
|
|
|
fieldWifiCountry.currentIndex = fieldWifiCountry.find("GB")
|
|
|
|
fieldWifiSSID.text = imageWriter.getSSID()
|
|
|
|
if (fieldWifiSSID.text.length) {
|
2023-03-10 18:37:22 +01:00
|
|
|
fieldWifiPassword.text = imageWriter.getPSK()
|
2021-01-17 17:43:17 +01:00
|
|
|
if (fieldWifiPassword.text.length) {
|
|
|
|
chkShowPassword.checked = false
|
2021-05-04 22:51:08 +02:00
|
|
|
if (Qt.platform.os == "osx") {
|
|
|
|
/* User indicated wifi must be prefilled */
|
|
|
|
chkWifi.checked = true
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
|
|
|
}
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var tz;
|
|
|
|
if ('timezone' in settings) {
|
|
|
|
chkLocale.checked = true
|
|
|
|
tz = settings.timezone
|
|
|
|
} else {
|
|
|
|
tz = imageWriter.getTimezone()
|
|
|
|
}
|
|
|
|
var tzidx = fieldTimezone.find(tz)
|
|
|
|
if (tzidx === -1) {
|
|
|
|
fieldTimezone.editText = tz
|
|
|
|
} else {
|
|
|
|
fieldTimezone.currentIndex = tzidx
|
|
|
|
}
|
|
|
|
if ('keyboardLayout' in settings) {
|
2021-11-22 00:21:30 +01:00
|
|
|
fieldKeyboardLayout.currentIndex = fieldKeyboardLayout.find(settings.keyboardLayout)
|
|
|
|
if (fieldKeyboardLayout.currentIndex == -1) {
|
|
|
|
fieldKeyboardLayout.editText = settings.keyboardLayout
|
|
|
|
}
|
2021-01-20 13:04:18 +01:00
|
|
|
} else {
|
2021-11-22 00:21:30 +01:00
|
|
|
if (imageWriter.isEmbeddedMode())
|
|
|
|
{
|
|
|
|
fieldKeyboardLayout.currentIndex = fieldKeyboardLayout.find(imageWriter.getCurrentKeyboard())
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Lacking an easy cross-platform to fetch keyboard layout
|
|
|
|
from host system, just default to "gb" for people in
|
|
|
|
UK time zone for now, and "us" for everyone else */
|
2023-10-16 13:09:34 +01:00
|
|
|
if (tz === "Europe/London") {
|
2021-11-22 00:21:30 +01:00
|
|
|
fieldKeyboardLayout.currentIndex = fieldKeyboardLayout.find("gb")
|
|
|
|
} else {
|
|
|
|
fieldKeyboardLayout.currentIndex = fieldKeyboardLayout.find("us")
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
|
2022-02-23 16:47:04 +01:00
|
|
|
if (imageWriter.isEmbeddedMode()) {
|
|
|
|
/* For some reason there is no password mask character set by default on Embedded edition */
|
|
|
|
var bulletCharacter = String.fromCharCode(0x2022);
|
|
|
|
fieldUserPassword.passwordCharacter = bulletCharacter;
|
|
|
|
fieldWifiPassword.passwordCharacter = bulletCharacter;
|
|
|
|
}
|
|
|
|
|
2021-01-20 13:04:18 +01:00
|
|
|
initialized = true
|
|
|
|
}
|
|
|
|
|
|
|
|
function openPopup() {
|
|
|
|
if (!initialized) {
|
|
|
|
initialize()
|
2023-10-02 19:50:36 +02:00
|
|
|
if (imageWriter.hasSavedCustomizationSettings())
|
|
|
|
{
|
|
|
|
applySettings()
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
|
|
|
|
2023-09-22 23:51:36 +02:00
|
|
|
//open()
|
|
|
|
show()
|
|
|
|
raise()
|
2022-02-03 11:38:51 +01:00
|
|
|
popupbody.forceActiveFocus()
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function addCmdline(s) {
|
|
|
|
cmdline += " "+s
|
|
|
|
}
|
|
|
|
function addConfig(s) {
|
|
|
|
config += s+"\n"
|
|
|
|
}
|
|
|
|
function addFirstRun(s) {
|
|
|
|
firstrun += s+"\n"
|
|
|
|
}
|
|
|
|
function escapeshellarg(arg) {
|
2022-10-15 15:21:39 +02:00
|
|
|
return "'"+arg.replace(/'/g, "'\"'\"'")+"'"
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
2021-11-18 20:48:24 +01:00
|
|
|
function addCloudInit(s) {
|
|
|
|
cloudinit += s+"\n"
|
|
|
|
}
|
|
|
|
function addCloudInitWriteFile(name, content, perms) {
|
|
|
|
cloudinitwrite += "- encoding: b64\n"
|
|
|
|
cloudinitwrite += " content: "+Qt.btoa(content)+"\n"
|
|
|
|
cloudinitwrite += " owner: root:root\n"
|
|
|
|
cloudinitwrite += " path: "+name+"\n"
|
|
|
|
cloudinitwrite += " permissions: '"+perms+"'\n"
|
|
|
|
}
|
|
|
|
function addCloudInitRun(cmd) {
|
|
|
|
cloudinitrun += "- "+cmd+"\n"
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
|
|
|
|
function applySettings()
|
|
|
|
{
|
|
|
|
cmdline = ""
|
|
|
|
config = ""
|
|
|
|
firstrun = ""
|
2021-11-18 20:48:24 +01:00
|
|
|
cloudinit = ""
|
|
|
|
cloudinitrun = ""
|
|
|
|
cloudinitwrite = ""
|
|
|
|
cloudinitnetwork = ""
|
2021-01-17 17:43:17 +01:00
|
|
|
|
|
|
|
if (chkHostname.checked && fieldHostname.length) {
|
|
|
|
addFirstRun("CURRENT_HOSTNAME=`cat /etc/hostname | tr -d \" \\t\\n\\r\"`")
|
2022-07-31 16:02:10 +02:00
|
|
|
addFirstRun("if [ -f /usr/lib/raspberrypi-sys-mods/imager_custom ]; then")
|
|
|
|
addFirstRun(" /usr/lib/raspberrypi-sys-mods/imager_custom set_hostname "+fieldHostname.text)
|
|
|
|
addFirstRun("else")
|
|
|
|
addFirstRun(" echo "+fieldHostname.text+" >/etc/hostname")
|
|
|
|
addFirstRun(" sed -i \"s/127.0.1.1.*$CURRENT_HOSTNAME/127.0.1.1\\t"+fieldHostname.text+"/g\" /etc/hosts")
|
|
|
|
addFirstRun("fi")
|
2021-11-18 20:48:24 +01:00
|
|
|
|
|
|
|
addCloudInit("hostname: "+fieldHostname.text)
|
|
|
|
addCloudInit("manage_etc_hosts: true")
|
|
|
|
addCloudInit("packages:")
|
|
|
|
addCloudInit("- avahi-daemon")
|
2022-01-20 17:24:25 +01:00
|
|
|
/* Disable date/time checks in apt as NTP may not have synchronized yet when installing packages */
|
|
|
|
addCloudInit("apt:")
|
|
|
|
addCloudInit(" conf: |")
|
|
|
|
addCloudInit(" Acquire {")
|
|
|
|
addCloudInit(" Check-Date \"false\";")
|
|
|
|
addCloudInit(" };")
|
2021-11-18 20:48:24 +01:00
|
|
|
addCloudInit("")
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
2022-01-20 17:24:25 +01:00
|
|
|
|
|
|
|
if (chkSSH.checked || chkSetUser.checked) {
|
2021-01-17 17:43:17 +01:00
|
|
|
// First user may not be called 'pi' on all distributions, so look username up
|
|
|
|
addFirstRun("FIRSTUSER=`getent passwd 1000 | cut -d: -f1`");
|
|
|
|
addFirstRun("FIRSTUSERHOME=`getent passwd 1000 | cut -d: -f6`")
|
|
|
|
|
2021-11-18 20:48:24 +01:00
|
|
|
addCloudInit("users:")
|
2021-11-19 23:30:42 +01:00
|
|
|
addCloudInit("- name: "+fieldUserName.text)
|
2021-11-19 21:45:47 +01:00
|
|
|
addCloudInit(" groups: users,adm,dialout,audio,netdev,video,plugdev,cdrom,games,input,gpio,spi,i2c,render,sudo")
|
2021-11-18 20:48:24 +01:00
|
|
|
addCloudInit(" shell: /bin/bash")
|
|
|
|
|
2022-01-31 14:26:08 +01:00
|
|
|
var cryptedPassword;
|
2022-01-20 17:24:25 +01:00
|
|
|
if (chkSetUser.checked) {
|
2022-01-31 14:26:08 +01:00
|
|
|
cryptedPassword = fieldUserPassword.alreadyCrypted ? fieldUserPassword.text : imageWriter.crypt(fieldUserPassword.text)
|
2021-11-18 20:48:24 +01:00
|
|
|
addCloudInit(" lock_passwd: false")
|
|
|
|
addCloudInit(" passwd: "+cryptedPassword)
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
2022-01-20 17:24:25 +01:00
|
|
|
|
|
|
|
if (chkSSH.checked && radioPubKeyAuthentication.checked) {
|
2021-12-20 21:46:37 +01:00
|
|
|
var pubkey = fieldPublicKey.text
|
|
|
|
var pubkeyArr = pubkey.split("\n")
|
2022-07-31 16:02:10 +02:00
|
|
|
var pubkeySpaceSep = ''
|
|
|
|
for (var j=0; j<pubkeyArr.length; j++) {
|
|
|
|
var pkitem = pubkeyArr[j].trim();
|
|
|
|
if (pkitem) {
|
|
|
|
pubkeySpaceSep += ' '+escapeshellarg(pkitem)
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
2022-07-31 16:02:10 +02:00
|
|
|
|
|
|
|
addFirstRun("if [ -f /usr/lib/raspberrypi-sys-mods/imager_custom ]; then")
|
|
|
|
addFirstRun(" /usr/lib/raspberrypi-sys-mods/imager_custom enable_ssh -k"+pubkeySpaceSep)
|
|
|
|
addFirstRun("else")
|
|
|
|
addFirstRun(" install -o \"$FIRSTUSER\" -m 700 -d \"$FIRSTUSERHOME/.ssh\"")
|
|
|
|
addFirstRun(" install -o \"$FIRSTUSER\" -m 600 <(printf \""+pubkey.replace(/\n/g, "\\n")+"\") \"$FIRSTUSERHOME/.ssh/authorized_keys\"")
|
|
|
|
addFirstRun(" echo 'PasswordAuthentication no' >>/etc/ssh/sshd_config")
|
|
|
|
addFirstRun(" systemctl enable ssh")
|
|
|
|
addFirstRun("fi")
|
2021-11-18 20:48:24 +01:00
|
|
|
|
2022-01-21 17:25:32 +01:00
|
|
|
if (!chkSetUser.checked) {
|
|
|
|
addCloudInit(" lock_passwd: true")
|
|
|
|
}
|
2021-11-18 20:48:24 +01:00
|
|
|
addCloudInit(" ssh_authorized_keys:")
|
2021-12-20 21:46:37 +01:00
|
|
|
for (var i=0; i<pubkeyArr.length; i++) {
|
|
|
|
var pk = pubkeyArr[i].trim();
|
|
|
|
if (pk) {
|
|
|
|
addCloudInit(" - "+pk)
|
|
|
|
}
|
|
|
|
}
|
2021-11-18 20:48:24 +01:00
|
|
|
addCloudInit(" sudo: ALL=(ALL) NOPASSWD:ALL")
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
2022-01-21 17:25:32 +01:00
|
|
|
addCloudInit("")
|
|
|
|
|
|
|
|
if (chkSSH.checked && radioPasswordAuthentication.checked) {
|
|
|
|
addCloudInit("ssh_pwauth: true")
|
2022-07-31 16:02:10 +02:00
|
|
|
addFirstRun("if [ -f /usr/lib/raspberrypi-sys-mods/imager_custom ]; then")
|
|
|
|
addFirstRun(" /usr/lib/raspberrypi-sys-mods/imager_custom enable_ssh")
|
|
|
|
addFirstRun("else")
|
|
|
|
addFirstRun(" systemctl enable ssh")
|
|
|
|
addFirstRun("fi")
|
2022-01-21 17:25:32 +01:00
|
|
|
}
|
2021-11-19 23:30:42 +01:00
|
|
|
|
2022-01-31 14:26:08 +01:00
|
|
|
if (chkSetUser.checked) {
|
|
|
|
/* 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(" usermod -l \""+fieldUserName.text+"\" \"$FIRSTUSER\"")
|
|
|
|
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(" sed /etc/lightdm/lightdm.conf -i -e \"s/^autologin-user=.*/autologin-user="+fieldUserName.text+"/\"")
|
|
|
|
addFirstRun(" fi")
|
|
|
|
addFirstRun(" if [ -f /etc/systemd/system/getty@tty1.service.d/autologin.conf ]; then")
|
|
|
|
addFirstRun(" sed /etc/systemd/system/getty@tty1.service.d/autologin.conf -i -e \"s/$FIRSTUSER/"+fieldUserName.text+"/\"")
|
|
|
|
addFirstRun(" fi")
|
|
|
|
addFirstRun(" if [ -f /etc/sudoers.d/010_pi-nopasswd ]; then")
|
|
|
|
addFirstRun(" sed -i \"s/^$FIRSTUSER /"+fieldUserName.text+" /\" /etc/sudoers.d/010_pi-nopasswd")
|
|
|
|
addFirstRun(" fi")
|
|
|
|
addFirstRun(" fi")
|
|
|
|
addFirstRun("fi")
|
|
|
|
}
|
2021-11-18 20:48:24 +01:00
|
|
|
addCloudInit("")
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
|
|
|
if (chkWifi.checked) {
|
|
|
|
var wpaconfig = "country="+fieldWifiCountry.editText+"\n"
|
|
|
|
wpaconfig += "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev\n"
|
|
|
|
wpaconfig += "ap_scan=1\n\n"
|
|
|
|
wpaconfig += "update_config=1\n"
|
|
|
|
wpaconfig += "network={\n"
|
2022-01-09 21:32:25 +00:00
|
|
|
if (chkWifiSSIDHidden.checked) {
|
|
|
|
wpaconfig += "\tscan_ssid=1\n"
|
|
|
|
}
|
2021-01-17 17:43:17 +01:00
|
|
|
wpaconfig += "\tssid=\""+fieldWifiSSID.text+"\"\n"
|
2021-04-11 14:09:28 +02:00
|
|
|
var cryptedPsk = fieldWifiPassword.text.length == 64 ? fieldWifiPassword.text : imageWriter.pbkdf2(fieldWifiPassword.text, fieldWifiSSID.text)
|
|
|
|
wpaconfig += "\tpsk="+cryptedPsk+"\n"
|
2021-01-17 17:43:17 +01:00
|
|
|
wpaconfig += "}\n"
|
|
|
|
|
2022-07-31 16:02:10 +02:00
|
|
|
addFirstRun("if [ -f /usr/lib/raspberrypi-sys-mods/imager_custom ]; then")
|
|
|
|
addFirstRun(" /usr/lib/raspberrypi-sys-mods/imager_custom set_wlan "
|
|
|
|
+(chkWifiSSIDHidden.checked ? " -h " : "")
|
|
|
|
+escapeshellarg(fieldWifiSSID.text)+" "+escapeshellarg(cryptedPsk)+" "+escapeshellarg(fieldWifiCountry.editText))
|
|
|
|
addFirstRun("else")
|
2021-04-11 14:09:28 +02:00
|
|
|
addFirstRun("cat >/etc/wpa_supplicant/wpa_supplicant.conf <<'WPAEOF'")
|
2021-01-17 17:43:17 +01:00
|
|
|
addFirstRun(wpaconfig)
|
|
|
|
addFirstRun("WPAEOF")
|
2022-07-31 16:02:10 +02:00
|
|
|
addFirstRun(" chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf")
|
|
|
|
addFirstRun(" rfkill unblock wifi")
|
|
|
|
addFirstRun(" for filename in /var/lib/systemd/rfkill/*:wlan ; do")
|
|
|
|
addFirstRun(" echo 0 > $filename")
|
|
|
|
addFirstRun(" done")
|
|
|
|
addFirstRun("fi")
|
|
|
|
|
2021-11-18 20:48:24 +01:00
|
|
|
|
|
|
|
cloudinitnetwork = "version: 2\n"
|
|
|
|
cloudinitnetwork += "wifis:\n"
|
|
|
|
cloudinitnetwork += " renderer: networkd\n"
|
|
|
|
cloudinitnetwork += " wlan0:\n"
|
|
|
|
cloudinitnetwork += " dhcp4: true\n"
|
|
|
|
cloudinitnetwork += " optional: true\n"
|
|
|
|
cloudinitnetwork += " access-points:\n"
|
2021-11-19 21:45:47 +01:00
|
|
|
cloudinitnetwork += " \""+fieldWifiSSID.text+"\":\n"
|
2021-11-18 20:48:24 +01:00
|
|
|
cloudinitnetwork += " password: \""+cryptedPsk+"\"\n"
|
2022-01-09 21:32:25 +00:00
|
|
|
if (chkWifiSSIDHidden.checked) {
|
|
|
|
cloudinitnetwork += " hidden: true\n"
|
|
|
|
}
|
2021-11-19 21:45:47 +01:00
|
|
|
|
2023-09-25 20:51:16 +02:00
|
|
|
addCmdline("cfg80211.ieee80211_regdom="+fieldWifiCountry.editText)
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
|
|
|
if (chkLocale.checked) {
|
2021-11-18 20:48:24 +01:00
|
|
|
var kbdconfig = "XKBMODEL=\"pc105\"\n"
|
2021-11-22 00:21:30 +01:00
|
|
|
kbdconfig += "XKBLAYOUT=\""+fieldKeyboardLayout.editText+"\"\n"
|
2021-11-18 20:48:24 +01:00
|
|
|
kbdconfig += "XKBVARIANT=\"\"\n"
|
|
|
|
kbdconfig += "XKBOPTIONS=\"\"\n"
|
|
|
|
|
2022-07-31 16:02:10 +02:00
|
|
|
addFirstRun("if [ -f /usr/lib/raspberrypi-sys-mods/imager_custom ]; then")
|
|
|
|
addFirstRun(" /usr/lib/raspberrypi-sys-mods/imager_custom set_keymap "+escapeshellarg(fieldKeyboardLayout.editText))
|
|
|
|
addFirstRun(" /usr/lib/raspberrypi-sys-mods/imager_custom set_timezone "+escapeshellarg(fieldTimezone.editText))
|
|
|
|
addFirstRun("else")
|
|
|
|
addFirstRun(" rm -f /etc/localtime")
|
|
|
|
addFirstRun(" echo \""+fieldTimezone.editText+"\" >/etc/timezone")
|
|
|
|
addFirstRun(" dpkg-reconfigure -f noninteractive tzdata")
|
2021-04-11 14:09:28 +02:00
|
|
|
addFirstRun("cat >/etc/default/keyboard <<'KBEOF'")
|
2021-11-18 20:48:24 +01:00
|
|
|
addFirstRun(kbdconfig)
|
2021-01-17 17:43:17 +01:00
|
|
|
addFirstRun("KBEOF")
|
2022-07-31 16:02:10 +02:00
|
|
|
addFirstRun(" dpkg-reconfigure -f noninteractive keyboard-configuration")
|
|
|
|
addFirstRun("fi")
|
2021-11-18 20:48:24 +01:00
|
|
|
|
|
|
|
addCloudInit("timezone: "+fieldTimezone.editText)
|
2021-11-25 01:34:13 +01:00
|
|
|
addCloudInitRun("localectl set-x11-keymap \""+fieldKeyboardLayout.editText+"\" pc105")
|
|
|
|
addCloudInitRun("setupcon -k --force || true")
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (firstrun.length) {
|
|
|
|
firstrun = "#!/bin/bash\n\n"+"set +e\n\n"+firstrun
|
|
|
|
addFirstRun("rm -f /boot/firstrun.sh")
|
|
|
|
addFirstRun("sed -i 's| systemd.run.*||g' /boot/cmdline.txt")
|
|
|
|
addFirstRun("exit 0")
|
|
|
|
/* using systemd.run_success_action=none does not seem to have desired effect
|
|
|
|
systemd then stays at "reached target kernel command line", so use reboot instead */
|
2021-11-18 20:48:24 +01:00
|
|
|
//addCmdline("systemd.run=/boot/firstrun.sh systemd.run_success_action=reboot systemd.unit=kernel-command-line.target")
|
|
|
|
// cmdline changing moved to DownloadThread::_customizeImage()
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cloudinitwrite !== "") {
|
|
|
|
addCloudInit("write_files:\n"+cloudinitwrite+"\n")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cloudinitrun !== "") {
|
|
|
|
addCloudInit("runcmd:\n"+cloudinitrun+"\n")
|
2021-01-17 17:43:17 +01:00
|
|
|
}
|
|
|
|
|
2021-11-18 20:48:24 +01:00
|
|
|
imageWriter.setImageCustomization(config, cmdline, firstrun, cloudinit, cloudinitnetwork)
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function saveSettings()
|
|
|
|
{
|
|
|
|
if (comboSaveSettings.currentIndex == 1) {
|
|
|
|
hasSavedSettings = true
|
|
|
|
var settings = { };
|
|
|
|
if (chkHostname.checked && fieldHostname.length) {
|
|
|
|
settings.hostname = fieldHostname.text
|
|
|
|
}
|
2022-02-01 16:02:50 +01:00
|
|
|
if (chkSetUser.checked) {
|
2021-11-19 23:30:42 +01:00
|
|
|
settings.sshUserName = fieldUserName.text
|
2022-02-01 16:02:50 +01:00
|
|
|
settings.sshUserPassword = fieldUserPassword.alreadyCrypted ? fieldUserPassword.text : imageWriter.crypt(fieldUserPassword.text)
|
|
|
|
}
|
|
|
|
|
|
|
|
settings.sshEnabled = chkSSH.checked
|
|
|
|
if (chkSSH.checked && radioPubKeyAuthentication.checked) {
|
|
|
|
settings.sshAuthorizedKeys = fieldPublicKey.text
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
|
|
|
if (chkWifi.checked) {
|
|
|
|
settings.wifiSSID = fieldWifiSSID.text
|
2022-02-03 18:57:41 +01:00
|
|
|
if (chkWifiSSIDHidden.checked) {
|
|
|
|
settings.wifiSSIDHidden = true
|
|
|
|
}
|
2022-02-04 12:42:50 +01:00
|
|
|
settings.wifiPassword = fieldWifiPassword.text.length == 64 ? fieldWifiPassword.text : imageWriter.pbkdf2(fieldWifiPassword.text, fieldWifiSSID.text)
|
2021-01-20 13:04:18 +01:00
|
|
|
settings.wifiCountry = fieldWifiCountry.editText
|
|
|
|
}
|
|
|
|
if (chkLocale.checked) {
|
|
|
|
settings.timezone = fieldTimezone.editText
|
2021-11-22 00:21:30 +01:00
|
|
|
settings.keyboardLayout = fieldKeyboardLayout.editText
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
imageWriter.setSavedCustomizationSettings(settings)
|
|
|
|
|
|
|
|
} else if (hasSavedSettings) {
|
|
|
|
imageWriter.clearSavedCustomizationSettings()
|
|
|
|
hasSavedSettings = false
|
|
|
|
}
|
|
|
|
|
2021-01-17 17:43:17 +01:00
|
|
|
imageWriter.setSetting("beep", chkBeep.checked)
|
|
|
|
imageWriter.setSetting("eject", chkEject.checked)
|
|
|
|
imageWriter.setSetting("telemetry", chkTelemtry.checked)
|
|
|
|
}
|
|
|
|
}
|