I have a script to format a drive, set permissions (777), copy a file, change permissions (555) and unmount and eject the drive for cinema DCPs. Currently everything is working but I'm getting an issue with chmod. Files copy from source to target drive with proper permissions so I'm not sure what the error is. Script and output below:
Script
#! /bin/bash
#Format Drive
sudo umount /dev/sda1
sudo parted -s /dev/sda mktable msdos
sudo parted /dev/sda mkpart primary ext3 1 100%
sudo wipefs -a /dev/sda1
sudo mkfs.ext3 -I 128 -L "DCP" /dev/sda1
#Update /etc/fstab
sudo mount -a
#Mount Drive
sudo mount /dev/sda1 /media/mynamehere/
#Set Permissions
sudo chmod -R 777 /media/mynamehere/DCP
#Copy Files to Target Drive
sudo rsync -av ~/Desktop/Source_Folder/ /media/mynamehere/DCP/
#Set Permissions
sudo chmod -R 555 /media/mynamehere/DCP
#Unmount Disk
sudo umount /dev/sda1
#Eject Disk
sudo eject /dev/sda1
Output
Information: You may need to update /etc/fstab.
mke2fs 1.43.5 (04-Aug-2017)
Creating filesystem with 3931904 4k blocks and 983040 inodes
Filesystem UUID: 68e0a893-3fe8-4daf-8ba0-3d5a285903fc
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
chmod: cannot access '/media/mynamehere/DCP': No such file or directory
sending incremental file list
created directory /media/mynamehere/DCP
./
ASSETMAP
CPL_DCP_SHR-2D_F-185_EN_51_2K_20180125_IOP_OV_a3b962d5-4e8d-46.xml
DCP_SHR-2D_F-185_EN_51_2K_20180125_IOP_OV_2707c99f-e757-44_j2c.mxf
DCP_SHR-2D_F-185_EN_51_2K_20180125_IOP_OV_fb719829-110f-4b_pcm.mxf
PKL_DCP_SHR-2D_F-185_EN_51_2K_20180125_IOP_OV_608bffb5-7d2d-49.xml
VOLINDEX
sent 1,117,023,702 bytes received 185 bytes 248,227,530.44 bytes/sec
total size is 1,116,750,369 speedup is 1.00