I am trying to write a script to automate imaging some USB flash drives. The idea is to run the script with the argument for the block device of the USB drive, then let the script remove partitioning, create partitions, then copy over a disk image.
Here is the script:
The first few lines were for testing, so I would know that when I passed the name of the block device, it would register properly. I had simply listed the commands, but after getting errors, I thought I'd try building functions. That didn't work either. Here is the results:
If I manually run the commands in the shell, everything works.
Can anyone tell me what I'm doing wrong?
Here is the script:
Code:
#!/bin/sh
echo $1
echo /dev/$1
echo /dev/${1}p1
clearpartition () {
gpart destroy -F $1
}
makebootpart () {
gpart create -s gpt $1
gpart add -t ms-basic-data -s 3782213632b $1
}
makebootimg () { dd if=zroot/shared/iso/EMU_STICK.img of=/dev/${1}p1 bs=1M conv=sync status=progress; }
makedatapart () {
gpart add -t ms-basic-data $1
mkexfatfs -n UTILS /dev/${1}p2
}
clearpartition
makebootpart
makebootimg
makedatapart
The first few lines were for testing, so I would know that when I passed the name of the block device, it would register properly. I had simply listed the commands, but after getting errors, I thought I'd try building functions. That didn't work either. Here is the results:
Code:
root@BQ751T2:/ # /usr/local/bin/emucreate.sh da0
da0
/dev/da0
/dev/da0p1
gpart: Invalid number of arguments.
gpart: Invalid number of arguments.
gpart: Invalid number of arguments.
If I manually run the commands in the shell, everything works.
Can anyone tell me what I'm doing wrong?