Skip to content

Instantly share code, notes, and snippets.

@adzhurinskij
Last active February 4, 2019 19:24
Show Gist options
  • Save adzhurinskij/ba80fa07bc0495e0e6a8303e32b55a3f to your computer and use it in GitHub Desktop.
Save adzhurinskij/ba80fa07bc0495e0e6a8303e32b55a3f to your computer and use it in GitHub Desktop.
Change MODX core path
#!/bin/bash
old_path='/home/old_site/public_html'
new_path='/home/new_site/public_html'
files="
./core/config/config.inc.php
./manager/config.core.php
./connectors/config.core.php
./config.core.php
"
SED=`which sed`
if [ ! -f `which gsed` ]; then
SED=`which gsed`
fi
TIMESTAMP=$(date +%Y-%m-%d_%Hh%Mm)
quote() {
echo "$1" | $SED 's/\//\\\//g'
}
old_path=`quote $old_path`
new_path=`quote $new_path`
for file in $files
do
if [ -f "$file" ]; then
echo patch $file
file_path=${file%/*}
file_name=`_t="${file%/}" && echo "${_t##*/}"`
# backup
cp $file_path/$file_name $file_path/${file_name}.${TIMESTAMP}
$SED -i "s/${old_path}/${new_path}/g" $file
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment