Skip to content

Instantly share code, notes, and snippets.

@danitfk
Last active September 23, 2019 15:12
Show Gist options
  • Save danitfk/88038d88827a2c9dd40d8d0a3658bfb1 to your computer and use it in GitHub Desktop.
Save danitfk/88038d88827a2c9dd40d8d0a3658bfb1 to your computer and use it in GitHub Desktop.
Fix directory path in OpenCart DirectAdmin to cPanel
#!/bin/bash
# Change /home directory if it's different
for filename in $(find /home/ -maxdepth 6 -name "config.php" | grep -E "public_html/config.php|public_html/admin/config.php")
do
echo "Filename: $filename"
for string in $(grep domains $filename | cut -d"," -f2 | cut -d\' -f2)
do
domain=$(echo $string | grep -o domains.* | cut -d/ -f2)
correct=$(echo $string | sed 's|domains/||g' | sed "s|/$domain||g")
if [[ -f "$filename.old" ]];
then
"Backup already existed"
else
cp $filename $filename.old
fi
owner=$(echo $string | cut -d"/" -f2)
chown $owner:$owner "$filename" "$filename.old"
sed -i "s|$string|$correct|g" $filename
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment