Created
May 19, 2012 04:08
-
-
Save eamexicano/2729022 to your computer and use it in GitHub Desktop.
Crear directorios archivos base para un proyecto básico en PHP. El archivo es sh se utiliza la terminal y necesita tener mysql en el $PATH (se tiene que estar ejecutando). Reescrito en PHP https://github.com/eamexicano/setup
This file contains 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 | |
if [ -n "$1" ]; then | |
echo "Creando directorios."; | |
mkdir "$1"; | |
cp resource.sh "$1"/resource.sh | |
cd "$1" | |
mkdir "config"; | |
mkdir "db"; | |
mkdir "assets"; | |
mkdir "assets/css"; | |
mkdir "assets/js"; | |
mkdir "assets/img"; | |
echo "Creando BD."; | |
tee readme.html > /dev/null <<SOURCE | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8' /> | |
<link rel="stylesheet" href="assets/css/$1.css" type="text/css" /> | |
</head> | |
<body> | |
<div class='container'> | |
<div class='header'> | |
<h1>$1</h1> | |
</div> | |
<div class='content'> | |
<h1>Hola</h1> | |
<p> | |
Este archivo es generado automáticamente. | |
</p> | |
</div> | |
<div class='footer'> | |
<p> | |
© $1 | |
</p> | |
</div> | |
</div> | |
</body> | |
</html> | |
SOURCE | |
tee assets/css/"$1".css > /dev/null <<SOURCE | |
body {font-family: 'helvetica neue', helvetica, sans-serif; font-size: 12px; line-height: 1.5; width: 980px; margin: 0 auto; color: #333;} | |
.container {width: 860px; margin: auto; } | |
.header {height: 40px; border-bottom: 1px solid #ccc;} | |
.content {height: 400px;} | |
.footer {height: 40px; border-top: 1px solid #ccc; text-align: right; color: #777;} | |
SOURCE | |
tee assets/js/"$1".js > /dev/null <<SOURCE | |
// Aquí va el código JS | |
SOURCE | |
echo "Creando archivo de conexion."; | |
echo "SOURCE -> config/conexion.php"; | |
tee config/conexion.php > /dev/null <<SOURCE | |
<?php | |
\$conexion = mysql_connect("127.0.0.1", "root","") or die ("Revisa host, usuario y password. " . mysql_error()); | |
\$db = mysql_select_db("$1") or die("Revisa el nombre de tu BD. " . mysql_error()); | |
mysql_query("SET NAMES UTF8"); | |
?> | |
SOURCE | |
echo "Creando BD."; | |
echo "SOURCE -> config/conexion.php"; | |
tee db/setup.sql > /dev/null <<SOURCE | |
CREATE DATABASE $1 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; | |
SOURCE | |
mysql -u root < db/setup.sql | |
else | |
echo "Intenta ejecutar setup.sh con un nombre". | |
echo "sh setup.sh miProyecto"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment