The Lounge 0001 [From the Beginning]

i couldnt get it working before because of the way the domain was setup.

The domain ran through cloudflares https thing vs me having my own lets encrypt key that the forum knows is being used

1 Like

I figured cloudflare was to blame. Letsencrypt FTW

1 Like

2 Likes

RIP gif :frowning:

2 Likes

gg

1 Like

So I made a shell script to create bootable Windows USBs on Linux. Its a little rough and could use some more work such as more checking on the usb device and general cleanup but is fine for the most part. Results are also repeatable when the script is ran so should minimize issues during the creation.

#!/bin/bash

if [[ $(id -u) -ne 0 ]]; then echo "Script must be ran as root"; exit 1; fi
if [[ -z $1 ]]; then echo "Specify path to iso image: $0 /path/to/iso"; exit 1; fi

while true; do
    disks=($(lsblk -dn --output NAME))
    echo "Choose a device"
    for i in "${!disks[@]}"; do
        echo "$i ${disks[$i]}"
    done
    read -p "device: "
    echo -e "\e[0;31mAre you sure /dev/${disks[$i]} is the correct device? All data will be erased? [Y/n] \033[0m"
    read go
    if [[ ${go,,} = "y" ]]; then
        device=/dev/${disks[$i]}
        if [ -n "$(mount | grep $device)" ]; then
            read -p "A partition is mounted on $device, do you want to umount it? [Y/n] " check
            if [[ ${check,,} = "y" ]]; then
                umount ${device}1
            else
                continue
            fi
        fi
        echo -e "Create parition table on $device (Select partition \033[1mtype 7\033[0m and \033[1mbootable\033[0m flag)"
        read -p "contiune [Y/n]: " go
        if [[ ${go,,} = "y" ]]; then
            cfdisk $device
            break
        else
            continue
        fi
    fi
done

mkfs.ntfs -f ${device}1
mbr="/usr/share/syslinux/mbr.bin"
if [ -f $mbr ]; then
    dd if=$mbr of=$device
else
    echo "Error: $mbr could not be found"
    exit 1
fi

mounts=("/tmp/iso" "/tmp/usb")
for i in "${!mounts[@]}"; do
    if [ ! -d ${mounts[$i]} ]; then
        mkdir -v ${mounts[$i]}
    fi
done

mount -vo loop $1 ${mounts[0]}
mount -v ${device}1 ${mounts[1]}

rsync -Prv ${mounts[0]}/ ${mounts[1]}
echo "Syncing device, This could take a while."
sync -f ${mounts[1]}

echo "Cleaning up..."
for i in "${!mounts[@]}"; do
    umount -v ${mounts[$i]}
    rmdir ${mounts[$i]}
done
1 Like

better than anything i could do XD

as for things that could be improved. i would verify that syslinux/mbr.bin is even there

1 Like

Thanks have added that and edited it into the post. What I really need to do next is check whether a filesystem is busy when I try and unmount as currently the script will continue even if it is.

1 Like
#!/bin/bash

mbr="/usr/share/syslinux/mbr.bin"
mounts=("/tmp/iso" "/tmp/usb")

if [[ $(id -u) -ne 0 ]]; then echo "Script must be ran as root"; exit 1; fi
if [[ -z $1 ]]; then echo "Specify path to iso image: $0 /path/to/iso"; exit 1; fi

while true; do
    disks=($(lsblk -dn --output NAME))
    echo "Choose a device"
    for i in "${!disks[@]}"; do
        echo "$i ${disks[$i]}"
    done
    read -p "device: "
    echo -e "\e[0;31mAre you sure /dev/${disks[$i]} is the correct device? All data will be erased? [Y/n] \033[0m"
    read go
    if [[ ${go,,} = "y" ]]; then
        device=/dev/${disks[$i]}
        if [ -n "$(mount | grep $device)" ]; then
            read -p "A partition is mounted on $device, do you want to umount it? [Y/n] " check
            if [[ ${check,,} = "y" ]]; then
                umount ${device}1
            else
                continue
            fi
        fi
        echo -e "Create parition table on $device (Select partition \033[1mtype 7\033[0m and \033[1mbootable\033[0m flag)"
        read -p "contiune [Y/n]: " go
        if [[ ${go,,} = "y" ]]; then
            cfdisk $device
            break
        else
            continue
        fi
    fi
done

mkfs.ntfs -f ${device}1
if [ -f $mbr ]; then
    dd if=$mbr of=$device
else
    echo "Error: $mbr could not be found"
    exit 1
fi

for i in "${!mounts[@]}"; do
    if [ ! -d ${mounts[$i]} ]; then
        mkdir -v ${mounts[$i]}
    fi
done

mount -vo loop $1 ${mounts[0]}
mount -v ${device}1 ${mounts[1]}

rsync -Prv ${mounts[0]}/ ${mounts[1]}
echo "Syncing device, This could take a while."
sync -f ${mounts[1]}

echo "Cleaning up..."
for i in "${!mounts[@]}"; do
    umount -v ${mounts[$i]}
    rmdir ${mounts[$i]}
done

moved a couple of varibles up to the top to make it easier to modify them :smiley:

1 Like

Nice that is much better. I should’ve thought of that sooner :smiley:

1 Like

I have made some improvements to the script and think I mostly have it to the point where I’d consider it done:

  • It now loops through every partition on the device and directs the user to unmount it.
  • More checking to see if a device is busy before unmounting
  • Minor visual improvements in the ui
  • Fixed an error where it would always select the bottom partition
#!/bin/bash

mbr="/usr/share/syslinux/mbr.bin"
mounts=("/tmp/iso" "/tmp/usb")

if [[ $(id -u) -ne 0 ]]; then echo "Script must be ran as root"; exit 1; fi
if [[ -z $1 ]]; then echo "Specify path to iso image: $0 /path/to/iso"; exit 1; fi

while true; do
    disks=($(lsblk -dnp --output NAME))
    echo "Choose a device"
    for i in "${!disks[@]}"; do
        echo "$i ${disks[$i]}"
    done
    read -p "device: " i
    echo -ne "\e[0;31mAre you sure ${disks[$i]} is the correct device? All data will be erased? [Y/n] \033[0m"
    read go
    if [[ ${go,,} = "y" ]]; then
        device=${disks[$i]}
        partitions=($(lsblk $device -fnpr --output NAME | sed -n '1!p'))
        for i in "${!partitions[@]}"; do
            mountpoint=$(lsblk ${partitions[$i]} -dn --output MOUNTPOINT)
            if [ -n "$(mount | grep ${partitions[$i]})" ]; then
                read -p "${partitions[$i]} is mounted on $mountpoint do you want to unmount it? [Y/n] " check
                if [[ ${check,,} = "y" ]]; then
                    if [ -n "$(fuser $mountpoint)" ]; then
                        echo "$mountpoint: target is busy"
                        continue 2
                    else
                        umount -v $mountpoint
                    fi
                else
                    continue 2
                fi
            fi
        done
        echo -e "Create parition table on $device (Select partition \033[1mtype 7\033[0m and \033[1mbootable\033[0m flag)"
        read -p "contiune [Y/n]: " go
        if [[ ${go,,} = "y" ]]; then
            cfdisk $device
            break
        else
            continue
        fi
    fi
done

mkfs.ntfs -f ${device}1
if [ -f $mbr ]; then
    dd if=$mbr of=$device
else
    echo "Error: $mbr could not be found"
    exit 1
fi

for i in "${!mounts[@]}"; do
    if [ ! -d ${mounts[$i]} ]; then
        mkdir -v ${mounts[$i]}
    fi
done

mount -vo loop $1 ${mounts[0]}
mount -v ${device}1 ${mounts[1]}

rsync -Prv ${mounts[0]}/ ${mounts[1]}
echo "Syncing device, This could take a while."
sync -f ${mounts[1]}

echo "Cleaning up..."
for i in "${!mounts[@]}"; do
    umount -v ${mounts[$i]}
    rmdir ${mounts[$i]}
done
1 Like

should make a thread about it :smiley:

1 Like

Yep I should, a good first step would be to actually comment my code :smile:

Rain and wind. Now it feels finally like fall.

2 Likes

i want snow

1 Like

I soo badly want snow again. it totally isn’t because I want to throw snowballs honest.

1 Like

i just like to eat snow

1 Like

eating snow is good just stay away from the yellow stuff :stuck_out_tongue:

1 Like

preceeds to dye clouds yellow

1 Like

I dread to think what you’ll use a dye.

1 Like