Creating USB startup disks for remastersys project
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 | #!/bin/bash
#Copy to USB Key Tool Copyright 2009,2011 by Tony Brijeski under the GPL V2
#Using yad for gui calls
DIALOG="`which yad`"
TITLE="--always-print-result --dialog-sep --image=/usr/share/icons/remastersys.png --title="
TITLETEXT="Remastersys USB Startup Disk Tool"
TEXT="--text="
ENTRY="--entry "
ENTRYTEXT="--entry-text "
FILESELECTION="--file-selection "
MENU="--list --column=Pick --column=Info"
PASSWORD="--entry --hide-text "
testroot="`whoami`"
if [ "$testroot" != "root" ]; then
remsu $0 &
exit
fi
copymenu () {
if [ "$1" = "(null)" ]; then
$DIALOG $TITLE"$TITLETEXT" $TEXT"\n\nYou must select a usb key to use. Click OK to return to main menu.\n"
mainmenu
fi
if [ "$2" = "(null)" ]; then
$DIALOG $TITLE"$TITLETEXT" $TEXT"\n\nYou must select a source to use. Click OK to return to main menu.\n"
mainmenu
fi
$DIALOG $TITLE"$TITLETEXT" $TEXT"\n\nThis will completely replace the contents of your usb drive with the Bootable Live System.\n\n \
You will not be able to undo this operation once it starts.\n\nClick OK to continue?\n"
if [ $? != 0 ]; then
mainmenu
fi
umount `mount | grep $1 | awk '{print $1}'`
progressbar "Copying to USB Key Now \n\nPlease Wait \n" &
#do the copy
dd if=$2 of=/dev/$1 bs=1M
sync
killall -KILL tail
$DIALOG $TITLE"$TITLETEXT" $TEXT"\n\nCopy to USB key completed. \nClick OK to return to main menu.\n"
mainmenu
}
progressbar () {
tail -f $0 | $DIALOG $TITLE"$TITLETEXT" $TEXT"$@" --progress --pulsate --auto-close
}
mainmenu () {
DEVS=""
DEVS=`ls -l /dev/disk/by-path/*usb* | grep -v "part" | awk '{print $NF}' | awk -F "/" '{print $NF}'`
if [ "$DEVS" != "" ]; then
for i in $DEVS; do
USBDRIVESIZE=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
USBDRIVES="$USBDRIVES!$i-$USBDRIVESIZE"
done
else
$DIALOG $TITLE"$TITLETEXT" $TEXT"\n\nNo USB Keys found.\n\n\nPlease insert a USB Key and then\nclick OK to return to main menu\nor Cancel to quit.\n"
if [ "$?" = "0" ]; then
mainmenu
else
exit
fi
fi
CHOICES=`$DIALOG $TITLE"$TITLETEXT" --form --field="USB Key:CB" $USBDRIVES --field="Source Image:FL" --button="Quit:2" --button="Copy to USB Key:1"`
retval="$?"
if [ "$retval" = "1" ]; then
USBDRIVE=`echo $CHOICES | cut -d "|" -f 1 | cut -d "-" -f 1`
PICKSOURCE=`echo $CHOICES | cut -d "|" -f 2`
copymenu $USBDRIVE $PICKSOURCE
else
exit
fi
}
mainmenu
|
View and moderate all "wiki Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Wiki"
Originally posted by: arjan.va...@gmail.com
Thanks for this handy tool! Hopefuly it will help me protect my drives for I use dd a lot and manage to erase important files multiple times a year becouse of stupid typo's and if/of mistakes... :s
I took the liberty of modifying the testroot statement to be more universal. This mod adds support for gksu(do), kdesu(do), beesu and sux....
!/bin/bash
Copy to USB Key Tool Copyright 2009,2011 by Tony Brijeski under the GPL V2 #Slightly modified by: Arjan van Lent, aka: Socialdefect 2013 #Using yad for gui calls
DIALOG="
which yad
" TITLE="--always-print-result --dialog-sep --image=/usr/share/icons/remastersys.png --title=" TITLETEXT="Remastersys USB Startup Disk Tool" TEXT="--text=" ENTRY="--entry " ENTRYTEXT="--entry-text " FILESELECTION="--file-selection " MENU="--list --column=Pick --column=Info" PASSWORD="--entry --hide-text "testroot="
whoami
"if
$testroot
!= "root" ; thenfi
copymenu () {
You will not be able to undo this operation once it starts.\n\nClick OK to continue?\n"
do the copy
}
progressbar () {
}
mainmenu () {
}
mainmenu