-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from kloptops/main
Updates!
- Loading branch information
Showing
8 changed files
with
135 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,77 @@ | ||
#!/bin/ash | ||
#!/bin/bash | ||
|
||
NEW_DATA_DIR="/mnt/SDCARD/Data/ports" | ||
LASTPWD="$PWD" | ||
cd /mnt/SDCARD/ | ||
|
||
OLD_SCRIPT_DIR="/mnt/SDCARD/Roms/PORTS" | ||
if [ -d "/mnt/SDCARD/ports" ]; then | ||
OLD_DATA_DIR="/mnt/SDCARD/ports" | ||
else | ||
OLD_DATA_DIR="/mnt/SDCARD/Ports" | ||
if [ -d "Data/ports" ]; then | ||
exit 0 | ||
fi | ||
|
||
if [ ! -d "$NEW_DATA_DIR" ]; then | ||
mkdir -p "$NEW_DATA_DIR" | ||
# Function to get the name of a directory with its original case sensitivity | ||
directory_name() { | ||
local dir="$1" | ||
local parent_dir=$(dirname "$dir") | ||
local original_dir=$(basename "$dir") | ||
local found_dir=$(find "$parent_dir" -maxdepth 1 -iname "$original_dir" -type d) | ||
|
||
echo "Moving $OLD_DATA_DIR to $NEW_DATA_DIR" | ||
for file in "$OLD_DATA_DIR"/*; do | ||
mv -v "$file" "$NEW_DATA_DIR" | ||
done | ||
if [ -n "$found_dir" ]; then | ||
echo "$found_dir" | ||
else | ||
echo "$original_dir" | ||
fi | ||
} | ||
|
||
echo "Moving $OLD_SCRIPT_DIR to $NEW_DATA_DIR" | ||
for file in "$OLD_SCRIPT_DIR"/*.sh; do | ||
cp -v "$file" "$NEW_DATA_DIR" | ||
done | ||
# Function to check if a directory exists, ignoring case sensitivity | ||
directory_exists() { | ||
local dir="$1" | ||
local parent_dir=$(dirname "$dir") | ||
local original_name=$(basename "$dir") | ||
local found | ||
found=$(find "$parent_dir" -maxdepth 1 -iname "$original_name" -type d) | ||
[ -n "$found" ] | ||
} | ||
|
||
if directory_exists "Data" && [ ! "$(directory_name "Data")" = "Data" ]; then | ||
# FUCK THIS SHIT | ||
mv_directory="$(directory_name "Data")" | ||
echo "Moving $mv_directory to portmaster_migration_backup" | tee -a "System/portmaster_migration.log" | ||
mkdir -p "portmaster_migration_backup" | ||
mv -v "$mv_directory" "portmaster_migration_backup/" | tee -a "System/portmaster_migration.log" | ||
fi | ||
|
||
if directory_exists "Data/ports" && [ ! "$(directory_name "Data/ports")" = "Data/ports" ]; then | ||
# Or this | ||
mv_directory="$(directory_name "Data/ports")" | ||
echo "Moving $mv_directory to portmaster_migration_backup" | tee -a "System/portmaster_migration.log" | ||
mkdir -p "portmaster_migration_backup" | ||
mv -v "$mv_directory" "portmaster_migration_backup/" | tee -a "System/portmaster_migration.log" | ||
fi | ||
|
||
if [ -d "/mnt/SDCARD/ports" ]; then | ||
rm -fR /mnt/SDCARD/ports | ||
mkdir -p /mnt/SDCARD/Ports | ||
# Okay this should be safe... | ||
if ! mkdir -p "Data/ports"; then | ||
# WELL FUCK. | ||
echo "Error: Failed to create Data/ports directory." | tee -a "System/portmaster_migration.log" | ||
cd "$LASTPWD" | ||
exit 1 | ||
fi | ||
|
||
# Move scripts and directories to Data/ports | ||
mv -v Roms/PORTS/*.sh Data/ports | tee -a "System/portmaster_migration.log" | ||
|
||
if directory_exists "ports"; then | ||
ports_directory="$(directory_name "ports")" | ||
mv -v "$ports_directory"/* "Data/ports" | tee -a "System/portmaster_migration.log" | ||
|
||
if [ ! -z "$(ls -A ports)" ]; then | ||
# If not empty, backup the directory, recreate Ports/ directory | ||
mkdir -p "portmaster_migration_backup" | ||
mv -v "$ports_directory" "portmaster_migration_backup/" | tee -a "System/portmaster_migration.log" | ||
else | ||
rm -fRv "$ports_directory" | tee -a "System/portmaster_migration.log" | ||
fi | ||
fi | ||
|
||
# Okay we made it to the end... | ||
mkdir -v "Ports" | tee -a "System/portmaster_migration.log" | ||
|
||
cd "$LASTPWD" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters