if test $blkstatus -eq 0
then
blklocation="/dev/mmcblk1p1"
blklocationforsed="dev/mmcblk1p1"
else
blklocation="/dev/mmcblk1"
blklocationforsed="dev/mmcblk1"
fi
filesystem=lsblk -no FSTYPE $blklocation
if [ "$filesystem" = "ntfs" ]; then
filesystem="ntfs-3g"
fi
sudo umount /opt/system/Tools
if [ "filesystem"="ext4"];thenfilesystem filesystem $blklocation /roms2 -o umask=0000,iocharset=utf8,uid=1002,gid=1002
fi
if [ ! -d "/roms2/videos/" ]; then
sudo mkdir /roms2/videos
fi
sudo mount /roms2/tools /opt/system/Tools
sed -i '//roms//s///roms2//' /etc/emulationstation/es_systems.cfg
if [ "filesystem"="ext4"];thensudosed−i′a/'"blklocationforsed"′\/roms2filesystem"' defaults,nofail,x-systemd.device-timeout=7 0 1' /etc/fstab
else
sudo sed -i 'a\/′"blklocationforsed"' /roms2 '"filesystem"' umask=0000,iocharset=utf8,noatime,nofail,x-systemd.device-timeout=7,uid=1002,gid=1002 0 0' /etc/fstab
fi
sudo sed -i '/roms\/tools/s//roms2\/tools/' /etc/fstab
sudo sed -i '/roms\/pico-8/s//roms2\/pico-8/g' /usr/local/bin/pico8.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/scummvm.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/ti99.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/dreamcast.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/doom.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/saturn.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/atomiswave.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/naomi.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/singe.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/easyrpg.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/ecwolf.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/drastic.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/ppsspp.sh
sudo sed -i '/roms\//s//roms2\//g' /opt/system/PS1\ -\ Generate\ m3u\ files.sh
sudo sed -i '/roms\//s//roms2\//g' /opt/system/PS1\ -\ Delete\ m3u\ files.sh
sed -i '/roms\//s//roms2\//' /home/ark/.CommanderGenius/cgenius.cfg
sed -i '/roms\//s//roms2\//g' /home/ark/.config/retroarch/retroarch.cfg
sed -i '/roms\//s//roms2\//g' /home/ark/.config/retroarch32/retroarch.cfg
sed -i '/roms\//s//roms2\//g' /home/ark/.atari800.cfg
sed -i '/roms\//s//roms2\//g' /home/ark/.config/retroarch/config/Atari800/retroarch_5200.cfg
sed -i '/roms\//s//roms2\//g' /home/ark/.config/retroarch/config/Atari800/retroarch_A800.cfg
sed -i '/roms\//s//roms2\//g' /home/ark/.config/retroarch/config/Atari800/retroarch_XEGS.cfg
sed -i '/roms\//s//roms2\//g' /home/ark/.config/mupen64plus/mupen64plus.cfg
sed -i '/roms\//s//roms2\//g' /home/ark/.config/duckstation/settings.ini
sed -i '/roms\/bios/s//roms2\/bios/g' /opt/amiberry/conf/amiberry.conf
sed -i '/.\/351Files 2/s//.\/351Files-sd2 2/g' /opt/system/351Files.sh
sudo sed -i '/roms\//s//roms2\//g' /usr/local/bin/scummvm.sh
sudo cp /usr/local/bin/Switch\ to\ main\ SD\ for\ Roms.sh /opt/system/Advanced/.
sudo rm /opt/system/Advanced/Switch\ to\ SD2\ for\ Roms.sh
sudo tar --strip-components=1 -xvkf /roms.tar -C /roms2/
#sudo mv -v -f -n /roms2/roms/* /roms2/
unlink /opt/hypseus/roms
ln -sfv /roms2/daphne/roms/ /opt/hypseus/roms
unlink /opt/hypseus-singe/singe
if [ ! -d "/roms2/alg/" ]; then
sudo mkdir /roms2/alg
fi
sudo cp -f -v -r /roms/alg/Scan_for_new_games.alg /roms2/alg/Scan_for_new_games.alg
sudo sed -i '/roms\//s//roms2\//g' /roms2/easyrpg/Scan_for_new_games.alg
ln -sfv /roms2/alg/ /opt/hypseus-singe/singe
unlink /home/ark/.emulationstation/music
ln -sfv /roms2/bgmusic/ /home/ark/.emulationstation/music
sudo sed -i '/roms\/scummvm/s//roms2\/scummvm/g' /roms2/scummvm/Scan_for_new_games.scummvm
sudo touch /roms2/scummvm/Scan_for_new_games.scummvm
sudo sed -i '/roms\/scummvm/s//roms2\/scummvm/g' /roms2/bios/scummvm.ini
sudo sed -i '/roms\/bios/s//roms2\/bios/g' /roms2/bios/scummvm.ini
sed -i '/roms\//s//roms2\//g' /home/ark/.config/scummvm/scummvm.ini
sed -i '/roms\//s//roms2\//g' /home/ark/.config/scummvm/scummvm.ini
sudo sed -i '/roms\//s//roms2\//g' /roms2/alg/Scan_for_new_games.alg
sudo cp -f -v -r /roms/easyrpg/Scan_for_new_games.easyrpg /roms2/easyrpg/Scan_for_new_games.easyrpg
sudo sed -i '/roms\//s//roms2\//g' /roms2/easyrpg/Scan_for_new_games.easyrpg
sudo cp -f -v -r /roms/wolf/Scan_for_new_games.wolf /roms2/wolf/Scan_for_new_games.wolf
sudo sed -i '/roms\//s//roms2\//g' /roms2/wolf/Scan_for_new_games.wolf
sudo sed -i '/roms\//s//roms2\//g' /roms2/psx/duckstation_gamesettings/*.ini
sudo cp -f -r -v /roms/ports/* /roms2/ports/
unlink /opt/drastic/backup
ln -sf /roms2/nds/backup/ /opt/drastic/backup
unlink /opt/drastic/cheats
ln -sf /roms2/nds/cheats/ /opt/drastic/cheats
unlink /opt/drastic/savestates
ln -sf /roms2/nds/savestates/ /opt/drastic/savestates
unlink /opt/drastic/slot2
ln -sf /roms2/nds/slot2/ /opt/drastic/slot2
unlink /home/ark/.config/ppsspp
ln -sf /roms2/psp/ppsspp/ /home/ark/.config/ppsspp
#sudo rm -rf /roms2/roms/
sudo cp -f /etc/samba/smb.conf.sd2 /etc/samba/smb.conf
if [ "filesystem" = "ext4" ]; then
sudo chown -R ark:ark /roms2/
fi
if [ ! -d "/roms2/wasm4/" ]; then
sudo mkdir /roms2/wasm4
fi
if [ ! -d "/roms2/thomson/" ]; then
sudo mkdir /roms2/thomson
fi
if [ ! -d "/roms2/enterprise/" ]; then
sudo mkdir /roms2/enterprise
fi
if [ ! -d "/roms2/tvc/" ]; then
sudo mkdir /roms2/tvc
fi
if [ ! -d "/roms2/palm/" ]; then
sudo mkdir /roms2/palm
fi
if [ ! -d "/roms2/coco3/" ]; then
sudo mkdir /roms2/coco3
fi
if [ ! -d "/roms2/videopac/" ]; then
sudo mkdir /roms2/videopac
fi
if [ ! -d "/roms2/apple2/" ]; then
sudo mkdir /roms2/apple2
fi
if [ ! -d "/roms2/piece/" ]; then
sudo mkdir /roms2/piece
fi
if [ ! -d "/roms2/scv/" ]; then
sudo mkdir /roms2/scv
fi
if [ ! -d "/roms2/vmac/" ]; then
sudo mkdir /roms2/vmac
fi
if [ ! -d "/roms2/puzzlescript/" ]; then
sudo mkdir /roms2/puzzlescript
fi
if [ ! -d "/roms2/vircon32/" ]; then
sudo mkdir /roms2/vircon32
fi
if [ ! -d "/roms2/j2me/" ]; then
sudo mkdir /roms2/j2me
fi
sudo pkill filebrowser
filebrowser -d /home/ark/.config/filebrowser.db users update ark --scope "/roms2"
printf "\n\n\e[32m$filesystem sdcard in slot2 is mounted to /roms2...\n"
printf "\033[0m"
sleep 3
printf "\033c" >> /dev/tty1
sudo swapoff /swapfile
sudo rm -f -v /swapfile
sudo systemctl restart emulationstation
else
printf "\n\n\e[91mCould not find a Fat, Fat32, Exfat, EXT4, or NTFS based sdcard to mount from slot2...\n"
printf "\033[0m"
sleep 5
printf "\033c" >> /dev/tty1
fi
нужно изменить код так что бы одновременно монтировались под названиями roms и roms2
To modify your script so that the SD card in slot 2 is mounted simultaneously under both /roms and /roms2, you can mount the SD card filesystem to both mount points. This eliminates the need to change paths from /roms/ to /roms2/ in your configuration files, as both directories will access the same content on the SD card.
Here's the modified script:
bash
#!/bin/bash
# Create /roms2 directory if it doesn't exist
if [ ! -d "/roms2/" ]; then
sudo mkdir /roms2
fi
# Determine the block device for the SD card in slot 2
blkchk=`lsblk -no FSTYPE /dev/mmcblk1p1`
blkstatus=$?
if test $blkstatus -eq 0
then
blklocation="/dev/mmcblk1p1"
blklocationforsed="dev\/mmcblk1p1"
else
blklocation="/dev/mmcblk1"
blklocationforsed="dev\/mmcblk1"
fi
# Get the filesystem type
filesystem=`lsblk -no FSTYPE $blklocation`
if [ "$filesystem" = "ntfs" ]; then
filesystem="ntfs-3g"
fi
sudo umount /opt/system/Tools
# Mount the SD card to /roms2
if [ "$filesystem" = "ext4" ]; then
sudo mount -t $filesystem $blklocation /roms2
else
sudo mount -t $filesystem $blklocation /roms2 -o umask=0000,iocharset=utf8,uid=1002,gid=1002
fi
# Check if the mount was successful
status=$?
if test $status -eq 0
then
# Mount the SD card to /roms as well
if [ ! -d "/roms" ]; then
sudo mkdir /roms
fi
if [ "$filesystem" = "ext4" ]; then
sudo mount -t $filesystem $blklocation /roms
else
sudo mount -t $filesystem $blklocation /roms -o umask=0000,iocharset=utf8,uid=1002,gid=1002
fi
# Setup swapfile
printf "\n\n\e[32mSetting up swapfile. Please wait...\n"
printf "\033[0m"
sudo dd if=/dev/zero of=/swapfile bs=1024 count=262144
sudo mkswap /swapfile
sudo swapon /swapfile
# Update /etc/fstab to mount at boot
if [ "$filesystem" = "ext4" ]; then
sudo sed -i '$a\/'"$blklocationforsed"' \/roms2 '"$filesystem"' defaults,nofail,x-systemd.device-timeout=7 0 1' /etc/fstab
sudo sed -i '$a\/'"$blklocationforsed"' \/roms '"$filesystem"' defaults,nofail,x-systemd.device-timeout=7 0 1' /etc/fstab
else
sudo sed -i '$a\/'"$blklocationforsed"' \/roms2 '"$filesystem"' umask=0000,iocharset=utf8,noatime,nofail,x-systemd.device-timeout=7,uid=1002,gid=1002 0 0' /etc/fstab
sudo sed -i '$a\/'"$blklocationforsed"' \/roms '"$filesystem"' umask=0000,iocharset=utf8,noatime,nofail,x-systemd.device-timeout=7,uid=1002,gid=1002 0 0' /etc/fstab
fi
# Kill any running filebrowser instances
sudo pkill filebrowser
# Update filebrowser user scope
filebrowser -d /home/ark/.config/filebrowser.db users update ark --scope "/roms2"
printf "\n\n\e[32m$filesystem SD card in slot 2 is mounted to /roms2 and /roms...\n"
printf "\033[0m"
sleep 3
printf "\033c" >> /dev/tty1
# Clean up swapfile
sudo swapoff /swapfile
sudo rm -f -v /swapfile
# Restart emulationstation
sudo systemctl restart emulationstation
else
printf "\n\n\e[91mCould not find a FAT, FAT32, exFAT, EXT4, or NTFS based SD card to mount from slot 2...\n"
printf "\033[0m"
sleep 5
printf "\033c" >> /dev/tty1
fi
Explanation of Changes:
Mount SD Card to Both /roms2 and /roms:
After mounting the SD card to /roms2, the script now also mounts it to /roms.
This is done using separate mount commands for each mount point.
Update /etc/fstab:
Entries for both /roms2 and /roms are added to /etc/fstab to ensure they are mounted automatically on boot.
Removed Path Adjustments:
Since both /roms and /roms2 point to the same SD card content, it's no longer necessary to change paths in configuration files from /roms/ to /roms2/.
Those sections of the script have been removed to simplify the process.
Important Notes:
Backup Existing /roms Directory:
Before running this script, ensure you have backups of any important data in your existing /roms directory.
Mounting the SD card to /roms will temporarily hide any existing files in /roms while the SD card is mounted.
If you have important data there, you might want to move it to the SD card or back it up elsewhere.
Filesystem Compatibility:
The script handles different filesystem types, including ext4, ntfs, and others.
Make sure the filesystem on your SD card is one of the supported types.
Permissions and Ownership:
The mount options ensure proper permissions and ownership, especially for non-ext4 filesystems.
Adjust uid and gid in the mount options if necessary to match your system's user IDs.
Swapfile Setup:
The script sets up a swapfile to assist with the mounting process.
After the mounting is complete, it removes the swapfile.
Service Restarts:
The script restarts services like emulationstation to ensure changes take effect.
It also restarts filebrowser with updated user scopes.
By making these changes, both /roms and /roms2 will access the SD card content simultaneously, and there's no need to modify configuration files to change paths. This should meet your requirement of having the SD card mounted under both names at the same time.
Disclaimer: Always make sure to test scripts in a safe environment before deploying them on your main system to prevent data loss or system issues.