Last active
          August 7, 2019 19:55 
        
      - 
      
- 
        Save efann/20ccea5546bff09eb7a9c5f74999ea29 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 7, 2019 | |
| # 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 bstrap_child 'BStrap 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" | |
| lcBase="THEMENAME" | |
| lcBootstrap="/var/www/$1/public_html/themes/bootstrap/starterkits/$lcBase" | |
| if [ ! -d "$lcThemes" ] | |
| then | |
| echo -e "\n$lcThemes does NOT exists. Exiting. . . .\n" | |
| exit 1 | |
| fi | |
| if [ ! -d "$lcBootstrap" ] | |
| then | |
| echo -e "\n$lcBootstrap does NOT exists. You probably need to install Bootstrap. 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 "$lcBootstrap" . | |
| mv "$lcBase/" "$2/" | |
| if [ ! -d "$lcThemes/$2" ] | |
| then | |
| echo -e "\n$2 does not exists. Exiting. . . .\n" | |
| exit 1 | |
| fi | |
| cd "$lcThemes/$2" | |
| echo -e "--------------------------------------------------------------\n" | |
| echo -e "$(pwd)" | |
| echo -e "--------------------------------------------------------------\n" | |
| echo -e "Renaming files. . . ." | |
| for lcFile in $(find -name "THEMENAME.*") | |
| do | |
| echo -e "Renaming $lcFile. . . ." | |
| rename "s/THEMENAME/$2/" "${lcFile}" | |
| done | |
| for lcFile in $(find -name "*.starterkit.*") | |
| do | |
| echo -e "Renaming $lcFile. . . ." | |
| rename "s/starterkit/info/" "${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/THEMENAME/$2/g" "${lcFile}" | |
| sed -i "s/THEMETITLE/$3/g" "${lcFile}" | |
| done | |
| 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