2023-10-22 16:54:14 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
TITLE="nanodesk-installer-gxm"
|
|
|
|
VERSION=$(cat /usr/share/nanodesk/version)
|
2023-10-22 21:17:15 +02:00
|
|
|
HEADER=" ----==== nanodesk-installer-gxm ====----
|
|
|
|
nanodesk ${VERSION}
|
|
|
|
"
|
2023-10-22 16:54:14 +02:00
|
|
|
|
|
|
|
GXMCMD="gxmessage -name $TITLE -center -geometry 669x420 -wrap -font mono,10 -file -"
|
2023-10-22 18:22:26 +02:00
|
|
|
|
2023-10-22 21:17:15 +02:00
|
|
|
GXMINFO="gxmessage -name $TITLE -center -buttons Close -default Close -font mono,13 -file -"
|
2023-10-22 18:22:26 +02:00
|
|
|
|
2023-10-22 16:54:14 +02:00
|
|
|
DOCROOT="/usr/share/doc/nanodesk-installer"
|
|
|
|
DILLOCMD="dillo -f -g 640x480 $DOCROOT"
|
|
|
|
|
2023-10-22 18:22:26 +02:00
|
|
|
TARGET=""
|
|
|
|
|
2023-10-22 19:41:13 +02:00
|
|
|
ERRORFILE="/tmp/nanodesk-installer.error"
|
|
|
|
SUCCESSFILE="/tmp/nanodesk-installer.success"
|
|
|
|
|
2023-10-22 16:54:14 +02:00
|
|
|
# initialize RETURN with a high value
|
|
|
|
RETURN=255
|
|
|
|
|
|
|
|
|
|
|
|
#####
|
|
|
|
#
|
|
|
|
# DIALOGES
|
|
|
|
#
|
|
|
|
#####
|
|
|
|
|
2023-10-22 18:22:26 +02:00
|
|
|
gxm-abort() {
|
2023-10-22 16:54:14 +02:00
|
|
|
|
2023-10-22 19:41:13 +02:00
|
|
|
if gxm-confirm
|
|
|
|
then
|
|
|
|
echo "Installation aborted!"| $GXMINFO
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
gxm-confirm() {
|
|
|
|
echo "Are you sure you want abort?" | $GXMINFO -buttons "Yes:0,No:1"
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
gxm-cleanup() {
|
|
|
|
echo "!!! An old Errorfile at $ERRORFILE was found !!!
|
|
|
|
|
|
|
|
It is necessary to delete it if you want to continue.
|
|
|
|
When deleting it, you will be asked for your password.
|
|
|
|
|
2023-10-22 19:56:21 +02:00
|
|
|
Last message was: $(cat $ERRORFILE)
|
|
|
|
|
2023-10-22 19:41:13 +02:00
|
|
|
Delete $ERRORFILE ?" | $GXMINFO -buttons "Yes:0,No:1" -default Yes
|
|
|
|
return $?
|
2023-10-22 16:54:14 +02:00
|
|
|
}
|
|
|
|
|
2023-10-22 18:22:26 +02:00
|
|
|
gxm-welcome() {
|
2023-10-22 21:17:15 +02:00
|
|
|
echo "$HEADER
|
2023-10-22 16:54:14 +02:00
|
|
|
This is a gxmessage based Installation assistant for nanodesk.
|
|
|
|
|
|
|
|
To install nanodesk you need a partitioned and formated drive.
|
2023-10-22 21:17:15 +02:00
|
|
|
You can do the partioning and formating with 'GParted'. (Close 'GParted'
|
|
|
|
when you are done)
|
2023-10-22 16:54:14 +02:00
|
|
|
|
|
|
|
If you need help how to do so, click on 'Help'.
|
|
|
|
|
|
|
|
When you are done partitioning and your installation target is formated,
|
2023-10-22 20:35:46 +02:00
|
|
|
go ahead with 'Install'.
|
|
|
|
|
2023-10-22 21:17:15 +02:00
|
|
|
When asked for a password, type in 'debian', which is the nanodesk live
|
|
|
|
default." |
|
2023-10-22 16:54:14 +02:00
|
|
|
$GXMCMD -buttons "Abort:1,Help:2,GParted:10,Install:0"
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2023-10-22 18:22:26 +02:00
|
|
|
gxm-select-target() {
|
2023-10-22 21:17:15 +02:00
|
|
|
echo "$HEADER
|
|
|
|
Please enter the target and press 'Install'.
|
2023-10-22 18:22:26 +02:00
|
|
|
For example: /dev/sda1" |
|
|
|
|
$GXMCMD -entry -buttons "Abort:1,Help:2,Install:0"
|
|
|
|
return $?
|
|
|
|
}
|
2023-10-22 19:41:13 +02:00
|
|
|
|
|
|
|
gmx-start-cli-installer() {
|
2023-10-22 21:17:15 +02:00
|
|
|
echo "$HEADER
|
|
|
|
The commandline nanodesk-installer will now open in a new xterm
|
2023-10-22 19:41:13 +02:00
|
|
|
window.
|
|
|
|
|
|
|
|
Target device: $1
|
|
|
|
|
|
|
|
Please follow the instructions there and see you later again..." |
|
|
|
|
$GXMCMD -buttons "Abort:1,open nanodesk-installer CLI:0" -default "open nanodesk-installer CLI"
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
gxm-success() {
|
2023-10-22 21:17:15 +02:00
|
|
|
echo "$HEADER
|
2023-10-22 19:56:21 +02:00
|
|
|
Installation complete! :)
|
2023-10-22 19:41:13 +02:00
|
|
|
|
|
|
|
You can now reboot or continue using nanodesk live." | $GXMCMD -buttons Continue:0,Reboot:2 -default Continue
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
gxm-error() {
|
2023-10-22 21:17:15 +02:00
|
|
|
echo "$HEADER
|
2023-10-22 19:56:21 +02:00
|
|
|
Installation FAILED!! :(
|
2023-10-22 19:41:13 +02:00
|
|
|
|
|
|
|
Last message was: $(cat $ERRORFILE)" | $GXMCMD -buttons Close -default Close
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-22 16:54:14 +02:00
|
|
|
#####
|
|
|
|
#
|
|
|
|
# HELP
|
|
|
|
#
|
|
|
|
#####
|
|
|
|
|
|
|
|
help-gparted() {
|
|
|
|
|
2023-10-22 21:17:15 +02:00
|
|
|
cat <<EOF | $GXMCMD
|
|
|
|
$HEADER
|
|
|
|
# Partitioning Help
|
|
|
|
|
|
|
|
## You have an empty drive
|
|
|
|
|
|
|
|
Cool, easiest way! When you have an empty drive, just start GParted
|
|
|
|
and select in the right up corner your correct drive you want to install
|
|
|
|
nanodesk on.
|
|
|
|
|
|
|
|
After that click in the upper Menu the entry 'Drive' and select
|
|
|
|
'create partitiontable'.
|
|
|
|
|
|
|
|
In the upcoming dialoge select 'ms-dos' abd 'Apply'.
|
|
|
|
|
|
|
|
Now right click in the empty bar representing your drive and select
|
|
|
|
'New'.
|
|
|
|
|
|
|
|
First we create your root filesystem. It gets most of the space, just
|
|
|
|
let around 4-8GB space left after free for a swap partition we create
|
|
|
|
afterwards.
|
|
|
|
|
|
|
|
Create as 'Primary' and select 'ext4' as filesystem. Confirm that with
|
|
|
|
'OK' and repeat the steps with the leftover diskspace and create a
|
|
|
|
partition with the 'linux-swap' filesystem.
|
|
|
|
|
|
|
|
When you done all this we need to activate our changes. Select 'Edit'
|
|
|
|
from the upper Menu and choose 'Apply All Operations' and confirm.
|
|
|
|
|
|
|
|
When all operations are done successfully, close GParted and click on
|
|
|
|
'Install' in the nanodesk-installer.
|
|
|
|
EOF
|
2023-10-22 16:54:14 +02:00
|
|
|
}
|
|
|
|
|
2023-10-22 18:22:26 +02:00
|
|
|
help-select-target() {
|
|
|
|
|
2023-10-22 21:17:15 +02:00
|
|
|
cat <<EOF | $GXMCMD
|
|
|
|
$HEADER
|
|
|
|
|
|
|
|
# target device
|
|
|
|
|
|
|
|
Here you have to enter the path to your drive with the
|
|
|
|
'ext4' filesystem on it. This could be in most cases for example
|
|
|
|
|
|
|
|
/dev/sda1
|
|
|
|
|
|
|
|
Which says it's the first drive in the system (sdA) and the first
|
|
|
|
partition on it (sda1).
|
|
|
|
|
|
|
|
If you are not sure, you can abort here and open nanodesk-installer
|
|
|
|
again. Open again GParted to verify that you choose the correct drive.
|
|
|
|
|
|
|
|
# commandline nanodesk-installer
|
|
|
|
|
|
|
|
In the next step the core of the installer, the commandline tool
|
|
|
|
`/usr/sbin/nanodesk-installer` opens up in a new xterm window.
|
|
|
|
|
|
|
|
Confirm the start of the installation by typing 'YES' all upper case
|
|
|
|
and confirm it by pressing [ENTER].
|
|
|
|
|
|
|
|
When the base system is installed, you can choose if you want to keep
|
|
|
|
the default user 'debian' with its password 'debian' (press [K])
|
|
|
|
or you also can remove this default user and create your own new one
|
|
|
|
(press [U]).
|
|
|
|
EOF
|
2023-10-22 18:22:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-22 16:54:14 +02:00
|
|
|
#####
|
|
|
|
#
|
|
|
|
# EXEC
|
|
|
|
#
|
|
|
|
#####
|
|
|
|
|
|
|
|
exec-gparted() {
|
|
|
|
pkexec /usr/sbin/gparted
|
|
|
|
}
|
|
|
|
|
2023-10-22 18:22:26 +02:00
|
|
|
exec-nanodesk-installer() {
|
2023-10-22 19:41:13 +02:00
|
|
|
# run the installer within xterm
|
2023-10-22 20:29:21 +02:00
|
|
|
xterm -e /bin/bash -c "pkexec /usr/sbin/nanodesk-installer $1 true || echo 'pkexec auth failed' >> $ERRORFILE"
|
2023-10-22 18:22:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#####
|
|
|
|
#
|
|
|
|
# MAIN
|
|
|
|
#
|
|
|
|
#####
|
2023-10-22 16:54:14 +02:00
|
|
|
|
2023-10-22 19:41:13 +02:00
|
|
|
# cleanup old errorfile
|
|
|
|
if [ -f "$ERRORFILE" ]
|
|
|
|
then
|
|
|
|
RETURN=255
|
|
|
|
while [ $RETURN -gt 0 ]
|
|
|
|
do
|
|
|
|
gxm-cleanup
|
|
|
|
RETURN=$?
|
|
|
|
|
|
|
|
if [ $RETURN -gt 0 ]
|
|
|
|
then
|
|
|
|
gxm-abort
|
|
|
|
else
|
|
|
|
pkexec rm -f $ERRORFILE || RETURN=255
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
RETURN=255
|
|
|
|
# welcome screen
|
2023-10-22 16:54:14 +02:00
|
|
|
while [ $RETURN -gt 0 ]
|
|
|
|
do
|
2023-10-22 18:22:26 +02:00
|
|
|
gxm-welcome
|
2023-10-22 16:54:14 +02:00
|
|
|
RETURN=$?
|
|
|
|
echo CODE $RETURN
|
|
|
|
case $RETURN in
|
2023-10-22 18:22:26 +02:00
|
|
|
1) gxm-abort ;;
|
2023-10-22 16:54:14 +02:00
|
|
|
2) help-gparted ;;
|
|
|
|
10) exec-gparted ;;
|
|
|
|
esac
|
|
|
|
done
|
2023-10-22 18:22:26 +02:00
|
|
|
|
2023-10-22 19:41:13 +02:00
|
|
|
# target select
|
2023-10-22 18:22:26 +02:00
|
|
|
RETURN=255
|
|
|
|
while [ $RETURN -gt 0 ]
|
|
|
|
do
|
|
|
|
TARGET=$(gxm-select-target)
|
|
|
|
RETURN=$?
|
|
|
|
echo CODE $RETURN
|
|
|
|
echo TARGET $TARGET
|
|
|
|
|
|
|
|
|
|
|
|
# if RC = 1, then user clicked "abort"
|
|
|
|
case $RETURN in
|
|
|
|
1) gxm-abort ;;
|
|
|
|
2) help-select-target ;;
|
|
|
|
0) echo test if blockdevice
|
|
|
|
if [ ! -b "$TARGET" ]
|
|
|
|
then
|
|
|
|
RETURN=255
|
|
|
|
echo no
|
|
|
|
echo -e "Error!\n'${TARGET}' does not exist or is not a blockdevice!" | $GXMINFO
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2023-10-22 19:41:13 +02:00
|
|
|
# start cli nanodesk-installer
|
|
|
|
RETURN=255
|
|
|
|
while [ $RETURN -gt 0 ]
|
|
|
|
do
|
|
|
|
gmx-start-cli-installer $TARGET
|
|
|
|
RETURN=$?
|
|
|
|
test $RETURN -eq 1 && gxm-abort
|
|
|
|
echo CODE $RETURN
|
|
|
|
done
|
|
|
|
|
2023-10-22 19:56:21 +02:00
|
|
|
exec-nanodesk-installer $TARGET
|
2023-10-22 19:41:13 +02:00
|
|
|
|
|
|
|
if [ -f "$SUCCESSFILE" ]
|
|
|
|
then
|
|
|
|
gxm-success
|
|
|
|
RETURN=$?
|
|
|
|
|
|
|
|
case $RETURN in
|
2023-10-22 21:17:15 +02:00
|
|
|
2) systemctl reboot ;;
|
2023-10-22 19:41:13 +02:00
|
|
|
*) exit 0 ;;
|
|
|
|
esac
|
|
|
|
elif [ -f "$ERRORFILE" ]
|
|
|
|
then
|
|
|
|
gxm-error
|
|
|
|
exit 1
|
2023-10-22 19:56:21 +02:00
|
|
|
else
|
|
|
|
echo "Unexpected Error! Exit here." | $GXMINFO -buttons Close -default Close
|
|
|
|
exit 1
|
2023-10-22 19:41:13 +02:00
|
|
|
fi
|
2023-10-22 18:22:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
#if [ $RETURN != 0 ]
|
|
|
|
#then
|
|
|
|
# echo "ERROR!" | $GXMINFO
|
|
|
|
# exit 1
|
|
|
|
#else
|
|
|
|
# echo "SUCCESS!" | $GXMINFO
|
|
|
|
# exit 0
|
|
|
|
#fi
|
|
|
|
|