Message ID | d8ef1780acd5729089b65f36902f17f8dfb4fc3c.1719927511.git.jan.kiszka@siemens.com |
---|---|
State | Accepted, archived |
Headers | show |
Series | Reworks, fixes and unattended mode for image installer | expand |
On Tue, 2024-07-02 at 15:38 +0200, 'Jan Kiszka' via isar-users wrote: > From: Jan Kiszka <jan.kiszka@siemens.com> > > If a special file called auto.install is found in the installation > data > directory, parse this and attempt an unattended installation. The > file > consists of 2 to 3 lines: > > - source file name > - target device path > - optionally, "OVERWRITE" to ignore if the target device is non-empty Ehm... did you forget to include a documentation update for this? Felix > > e.g.: > $ cat /install/auto.install > isar-image-base-debian-bookworm-qemuamd64.wic.zst > /dev/vda > OVERWRITE > > Errors are still stopping the process, switching it back to > interactive > mode. > > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> > --- > .../deploy-image/files/deploy-image-wic.sh | 16 > ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/meta-isar/recipes-installer/deploy-image/files/deploy- > image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/deploy- > image-wic.sh > index 9df93fe7..8b25b1d2 100644 > --- a/meta-isar/recipes-installer/deploy-image/files/deploy-image- > wic.sh > +++ b/meta-isar/recipes-installer/deploy-image/files/deploy-image- > wic.sh > @@ -7,8 +7,20 @@ > installdata=${INSTALL_DATA:-/install} > > AUTO_INSTALL=false > +OVERWRITE= > > -if ! $AUTO_INSTALL; then > +if [ -f "$installdata/auto.install" ]; then > + exec 3<"$installdata/auto.install" > + read -r DISK_IMAGE <&3 > + read -r TARGET_DEVICE <&3 > + read -r OVERWRITE <&3 > + exec 3>&- > + if [ ! -b ${TARGET_DEVICE} ]; then > + dialog --msgbox "Target device is not a valid block device. > Installation aborted." 6 60 > + exit 1 > + fi > + AUTO_INSTALL=true > +else > DISK_IMAGE=$(find "$installdata" -type f -iname "*.wic*" -a -not > -iname "*.wic.bmap" -exec basename {} \;) > if [ -z "$DISK_IMAGE" ] || [ ! -f "$installdata/$DISK_IMAGE" ]; > then > pushd "$installdata" > @@ -110,7 +122,7 @@ if ! $AUTO_INSTALL; then > fi > fi > > -if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M && \ > +if [ "$OVERWRITE" != "OVERWRITE" ] && ! cmp /dev/zero > "$TARGET_DEVICE" -n 1M && \ > ! dialog --defaultno \ > --yesno "WARNING: Target device is not empty! Continue > anyway?" 5 60; then > exit 0 > -- > 2.43.0 >
On 03.07.24 17:56, Moessbauer, Felix (T CED OES-DE) wrote: > On Tue, 2024-07-02 at 15:38 +0200, 'Jan Kiszka' via isar-users wrote: >> From: Jan Kiszka <jan.kiszka@siemens.com> >> >> If a special file called auto.install is found in the installation >> data >> directory, parse this and attempt an unattended installation. The >> file >> consists of 2 to 3 lines: >> >> - source file name >> - target device path >> - optionally, "OVERWRITE" to ignore if the target device is non-empty > > Ehm... did you forget to include a documentation update for this? > Not forgotten - not yet done. At some point I first wanted to send out the longer and longer queue. Jan > Felix > >> >> e.g.: >> $ cat /install/auto.install >> isar-image-base-debian-bookworm-qemuamd64.wic.zst >> /dev/vda >> OVERWRITE >> >> Errors are still stopping the process, switching it back to >> interactive >> mode. >> >> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> >> --- >> .../deploy-image/files/deploy-image-wic.sh | 16 >> ++++++++++++++-- >> 1 file changed, 14 insertions(+), 2 deletions(-) >> >> diff --git a/meta-isar/recipes-installer/deploy-image/files/deploy- >> image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/deploy- >> image-wic.sh >> index 9df93fe7..8b25b1d2 100644 >> --- a/meta-isar/recipes-installer/deploy-image/files/deploy-image- >> wic.sh >> +++ b/meta-isar/recipes-installer/deploy-image/files/deploy-image- >> wic.sh >> @@ -7,8 +7,20 @@ >> installdata=${INSTALL_DATA:-/install} >> >> AUTO_INSTALL=false >> +OVERWRITE= >> >> -if ! $AUTO_INSTALL; then >> +if [ -f "$installdata/auto.install" ]; then >> + exec 3<"$installdata/auto.install" >> + read -r DISK_IMAGE <&3 >> + read -r TARGET_DEVICE <&3 >> + read -r OVERWRITE <&3 >> + exec 3>&- >> + if [ ! -b ${TARGET_DEVICE} ]; then >> + dialog --msgbox "Target device is not a valid block device. >> Installation aborted." 6 60 >> + exit 1 >> + fi >> + AUTO_INSTALL=true >> +else >> DISK_IMAGE=$(find "$installdata" -type f -iname "*.wic*" -a -not >> -iname "*.wic.bmap" -exec basename {} \;) >> if [ -z "$DISK_IMAGE" ] || [ ! -f "$installdata/$DISK_IMAGE" ]; >> then >> pushd "$installdata" >> @@ -110,7 +122,7 @@ if ! $AUTO_INSTALL; then >> fi >> fi >> >> -if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M && \ >> +if [ "$OVERWRITE" != "OVERWRITE" ] && ! cmp /dev/zero >> "$TARGET_DEVICE" -n 1M && \ >> ! dialog --defaultno \ >> --yesno "WARNING: Target device is not empty! Continue >> anyway?" 5 60; then >> exit 0 >> -- >> 2.43.0 >> >
diff --git a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh index 9df93fe7..8b25b1d2 100644 --- a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh +++ b/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh @@ -7,8 +7,20 @@ installdata=${INSTALL_DATA:-/install} AUTO_INSTALL=false +OVERWRITE= -if ! $AUTO_INSTALL; then +if [ -f "$installdata/auto.install" ]; then + exec 3<"$installdata/auto.install" + read -r DISK_IMAGE <&3 + read -r TARGET_DEVICE <&3 + read -r OVERWRITE <&3 + exec 3>&- + if [ ! -b ${TARGET_DEVICE} ]; then + dialog --msgbox "Target device is not a valid block device. Installation aborted." 6 60 + exit 1 + fi + AUTO_INSTALL=true +else DISK_IMAGE=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;) if [ -z "$DISK_IMAGE" ] || [ ! -f "$installdata/$DISK_IMAGE" ]; then pushd "$installdata" @@ -110,7 +122,7 @@ if ! $AUTO_INSTALL; then fi fi -if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M && \ +if [ "$OVERWRITE" != "OVERWRITE" ] && ! cmp /dev/zero "$TARGET_DEVICE" -n 1M && \ ! dialog --defaultno \ --yesno "WARNING: Target device is not empty! Continue anyway?" 5 60; then exit 0