Skip to content

Instantly share code, notes, and snippets.

@afeijo
Last active December 21, 2015 04:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afeijo/6252896 to your computer and use it in GitHub Desktop.
Save afeijo/6252896 to your computer and use it in GitHub Desktop.
Bash script to create the skeleton files for a new Drupal 7 module
#!/bin/bash
# usage: download the script, place it in the modules folder, and execute with your new module name as the parameter.
# bash new_module.sh CustomModule
mkdir $1
cd $1
## .info file
echo "name = $1" > $1.info
echo "description = description" >> $1.info
echo "core = 7.x" >> $1.info
## .module file
echo "<?php" > $1.module
echo "" >> $1.module
echo "function $1_menu() {" >> $1.module
echo " \$items = array();" >> $1.module
echo " return \$items;" >> $1.module
echo "}" >> $1.module
## .install file
echo "<?php" > $1.install
echo "" >> $1.install
echo "function $1_install() {" >> $1.install
echo " " >> $1.install
echo "}" >> $1.install
echo "" >> $1.install
echo "function $1_uninstall() {" >> $1.install
echo " " >> $1.install
echo "}" >> $1.install
echo "$1 module created"
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment