Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update composer-post-install.sh #761

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions bin/composer-post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ fi


MOJ_COMPONENTS_FILE=/var/www/html/public/app/mu-plugins/wp-moj-components/component/Introduce/Introduce.php
MOJ_COMPONENTS_SEARCH_1="justice\.web@digital\.justice\.gov\.uk"
MOJ_COMPONENTS_REPLACE_1="[email protected]"
MOJ_COMPONENTS_SEARCH_2="Justice\son\sthe\sWeb\steam"
MOJ_COMPONENTS_REPLACE_2="Central Digital Product Team"
MOJ_COMPONENTS_SEARCH_EMAIL="justice\.web@digital\.justice\.gov\.uk"
MOJ_COMPONENTS_REPLACE_EMAIL="[email protected]"

# If search string is in file. Then replace it.
if grep -q $MOJ_COMPONENTS_SEARCH_1 $MOJ_COMPONENTS_FILE ; then
if grep -q $MOJ_COMPONENTS_SEARCH_EMAIL $MOJ_COMPONENTS_FILE ; then
echo "Replacing email text in wp-moj-components plugin."
sed -i "s/$MOJ_COMPONENTS_SEARCH_1/$MOJ_COMPONENTS_REPLACE_1/g" $MOJ_COMPONENTS_FILE
sed -i "s/$MOJ_COMPONENTS_SEARCH_EMAIL/$MOJ_COMPONENTS_REPLACE_EMAIL/g" $MOJ_COMPONENTS_FILE
fi

if grep -q $MOJ_COMPONENTS_SEARCH_2 $MOJ_COMPONENTS_FILE ; then
echo "Replacing team text in wp-moj-components plugin."
sed -i "s/'$MOJ_COMPONENTS_SEARCH_2'/'$MOJ_COMPONENTS_REPLACE_2'/g" $MOJ_COMPONENTS_FILE
MOJ_COMPONENTS_SEARCH_PARAGRAPH="<p>This website is ([\w\W]*?)<\/p>"
MOJ_COMPONENTS_REPLACE_PARAGRAPH="<p>This website is technically maintained by Justice Digital, Central Digital Product Team:<\/p>"

if [ -f "$MOJ_COMPONENTS_FILE" ] ; then
echo "Replacing paragraph text in wp-moj-components plugin"
MOJ_COMPONENTS_CONTENT=$(perl -0777pe 's/'"$MOJ_COMPONENTS_SEARCH_PARAGRAPH"'/'"$MOJ_COMPONENTS_REPLACE_PARAGRAPH"'/s' "$MOJ_COMPONENTS_FILE")
echo "$MOJ_COMPONENTS_CONTENT" > "$MOJ_COMPONENTS_FILE"
fi
Loading