#!/bin/bash # torios version if [ "$1" == "" ] || [ "$USER" != "root" ] || ! test -b "$1" then echo "usage: sudo $0 " echo "example: sudo $0 /dev/sdd" exit fi lsblk -o MODEL,NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE "$1" read -p "Go ahead and overwrite $1 ? (g/q) " ans if [ "$ans" != "g" ] then exit fi read -p "FINAL WARNING: Are you sure $1 ? (y/n) " ans if [ "$ans" != "y" ] then exit fi if test -f syslinux.cfg then echo "Using 'syslinux.cfg' in the current directory" else echo "'syslinux.cfg' not found in the current directory" exit fi source=torios.iso # torios if test -f "$source" then echo "Using '$source' in the current directory" else echo "'$source' not found in the current directory" exit fi umount /mnt part="${1}1" #umount "$part" #df|grep "$part" umount ${1}? df|grep ${1} if [ $? -eq 0 ] then echo "Cannot unmount a partition on the target device" exit fi dd if=/dev/zero of="$1" bs=1024 count=1024 echo "---------------------------------------------------------------------------" echo " Use gparted" echo "---------------------------------------------------------------------------" echo "Suggested values, may be changed according to the size of '$source'" echo "${1}1: file system=fat32 size=1-2 GB to host config and iso files" echo "${1}2: file system=ext2 size=rest of device" sleep 2 gparted "$1" #mkudffs -b 512 --media-type=dvdram "$part" persist=live # torios mkfs.vfat -n ToriPersist "$part" tune2fs -L "${persist}-rw" "${1}2" mount "$part" /mnt echo "---------------------------------------------------------------------------" echo " Use Unetbootin" echo "---------------------------------------------------------------------------" echo "Use a current local ToriOS iso file if available (copy and paste) " echo "$(pwd)/torios.iso" echo " Do not use Unetbootin's persistence (keep it at 0 MB))" echo "Check and change the selected target drive, should be $part" sudo -H unetbootin cp syslinux.cfg /mnt if [ $? != 0 ] then echo "Too small partition: \'$source\'" fi sync echo "Syncing the target device ..." umount "$part" if [ $? -eq 0 ] then lsblk -o MODEL,NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE "$1" echo "The target device is ready to use." echo "It contains the source file '$source'" else echo "Could not unmount the target device. Try manually!" fi