Last active
August 14, 2017 20:42
-
-
Save efann/897b4363ed59a874daf949dfdb037fd5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
# Updated on August 14, 2017 | |
# If not exactly 3 arguments. . . . | |
if [ ! $# == 3 ] | |
then | |
echo -e "\nOne must pass the Drupal folder name under /var/www, the new subtheme machine name and new subtheme title.\n\n" | |
echo -e "For example, $0 Fred.com adminimal_child 'Adminimal Child'\n\n" | |
echo -e "Exiting. . . .\n\n" | |
exit 1 | |
fi | |
# Must not run as root. . . . | |
if [[ $EUID -eq 0 ]] | |
then | |
echo -e "\nThis script should NOT be run as root." | |
exit 1 | |
fi | |
lcThemes="/var/www/$1/public_html/themes" | |
lcAdminimal="/var/www/$1/public_html/themes/adminimal_theme" | |
if [ ! -d "$lcThemes" ] | |
then | |
echo -e "\n$lcThemes does NOT exists. Exiting. . . .\n" | |
exit 1 | |
fi | |
if [ ! -d "$lcAdminimal" ] | |
then | |
echo -e "\n$lcAdminimal does NOT exists. You probably need to install Adminimal Theme. Exiting. . . .\n" | |
exit 1 | |
fi | |
if [ -d "$lcThemes/$2" ] | |
then | |
echo -e "\n$2 already exists. Exiting. . . .\n" | |
exit 1 | |
fi | |
pushd "$lcThemes" | |
cp -R "$lcAdminimal" "./$2" | |
if [ ! -d "$lcThemes/$2" ] | |
then | |
echo -e "\n$lcThemes/$2 could not be created. Exiting. . . .\n" | |
exit 1 | |
fi | |
cd "$lcThemes/$2" | |
echo -e "--------------------------------------------------------------\n" | |
echo -e "Removing css and images folders. . . ." | |
mv ./css/adminimal.css "./css/$2.css" | |
rm -rf ./images | |
echo -e "--------------------------------------------------------------\n" | |
echo -e "Renaming files (find -name '*adminimal_theme*'). . . ." | |
for lcFile in $(find . -name "*adminimal_theme*") | |
do | |
echo -e "Renaming $lcFile. . . ." | |
rename "s/adminimal_theme/$2/" "${lcFile}" | |
done | |
echo -e "--------------------------------------------------------------\n" | |
echo -e "Replacing text using sed. . . .\n" | |
for lcFile in $(find -name "*.yml") | |
do | |
echo -e "$lcFile" | |
sed -i "s/adminimal_theme/$2/g" "${lcFile}" | |
done | |
echo -e "--------------------------------------------------------------\n" | |
echo -e "Fixing titles et al. . . ." | |
sed -i "s/name: Adminimal/name: $3/g" "$2.info.yml" | |
sed -i "s/base theme: seven/base theme: adminimal_theme/g" "$2.info.yml" | |
sed -i '/# Information/Q' "$2.info.yml" | |
sed -i 's/# core:/core:/g' "$2.info.yml" | |
sed -i "s/adminimal.css/$2.css/g" "$2.libraries.yml" | |
lcCSSText="/* $3 overrides file. All selectors must start with ".adminimal" */\n\n" | |
echo -e "$lcCSSText" > "./css/$2.css" | |
lcThemeText="<?php\n\n/**\n * @file\n * Functions to support theming in the $3 theme.\n */\n" | |
echo -e "$lcThemeText" > "$2.theme" | |
echo -e "--------------------------------------------------------------\n" | |
echo -e "Done\n" | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment