Skip to content

Instantly share code, notes, and snippets.

@gpittau
Created January 18, 2012 18:18
Show Gist options
  • Save gpittau/1634626 to your computer and use it in GitHub Desktop.
Save gpittau/1634626 to your computer and use it in GitHub Desktop.
#!/bin/bash -ex
USERNAME=salutte
HOSTNAME=salutte
VERSION=2.0
DB_NAME=salutte2
install()
{
DEBIAN_FRONTEND=noninteractive apt-get -y \
-o DPkg::Options::=--force-confdef \
-o DPkg::Options::=--force-confold \
install $@
}
# Set Hostname
echo "$HOSTNAME" > /etc/hostname
sed -i "s|127.0.1.1 \(.*\)|127.0.1.1 $HOSTNAME|" /etc/hosts
hostname salutte
#Update package information
apt-get update
# Install required packages
install
#PHP5
install php5-cli php5-gd php5-curl php5-xsl
#RESOLVER EL ISSUE: https://github.com/SIGMA-IT/Salutte-Framework/issues/2
#install php-apc
#opcionales
#install sudo
install byobu
#localtime en Buenos Aires
ln -sf /usr/share/zoneinfo/America/Argentina/Buenos_Aires /etc/localtime
#crea el usuario $USERNAME
useradd -s /usr/bin/byobu $USERNAME
# importante!!! execute "passwd $USERNAME" to activate user account
chown -R $USERNAME:$USERNAME /home/$USERNAME
usermod -aG www-data $USERNAME
usermod -aG $USERNAME www-data
chown -R www-data:www-data /var/www
chmod -R 775 /var/www
#enable mod_rewrite
a2enmod rewrite
#inhabilita la regenearion de certificados
chmod -x /usr/lib/inithooks/firstboot.d/10regen-sshkeys
#chmod -x /usr/lib/inithooks/firstboot.d/10regen-sslcert
chmod -x /usr/lib/inithooks/firstboot.d/84salutte-install
#aqui vienen las claves (desactivar con manejo mejorado de claves)
. /etc/default/inithooks
#previo a Ãsto hay que tener configurada una cuenta de github con acceso al repo
su - $USERNAME <<AS_SALUTTE
git clone git@github.com:SIGMA-IT/Salutte2.git
pushd Salutte2
git checkout $VERSION
git submodule update --init --recursive
popd
git clone git@github.com:SIGMA-IT/Salutte-Framework.git
pushd Salutte-Framework
git checkout $VERSION
git submodule update --init --recursive
popd
AS_SALUTTE
service mysql start
#mysqladmin -u root create $DB_NAME
#mysql -u root $DB_NAME<$DB_NAME.sql
#rm $DB_NAME.sql
#crea el user y grants
mysql -u root <<SQL
create
user 'root'@'%'
identified
by '$DB_PASS'
;
grant
all privileges
on *.*
to 'root'@'%'
with
grant option
MAX_QUERIES_PER_HOUR 0
MAX_CONNECTIONS_PER_HOUR 0
MAX_UPDATES_PER_HOUR 0
MAX_USER_CONNECTIONS 0
;
SQL
#crea la BD
mysql -u root <<SQL
drop
database
if exists $DB_NAME
;
create
database $DB_NAME
default charset=utf8
default collate=utf8_spanish_ci
;
SQL
#aplica el dump
mysql -u root -D$DB_NAME </home/$USERNAME/$DB_NAME.dump.sql
rm /home/$USERNAME/$DB_NAME.dump.sql
#crea el dir de los Proxies
#mkdir -p /home/$USERNAME/Salutte2/application/modules/Proxies
pushd /home/$USERNAME/Salutte2/sandbox
./doctrine2 $DB_NAME orm:generate-proxies
popd
pushd /home/$USERNAME/Salutte2/application/modules
chown -R $USERNAME:$USERNAME Proxies
chmod -R g+w Proxies
popd
#linkea el dir
ln -sf /home/$USERNAME/Salutte2 /var/www/Salutte2
service mysql stop
# Clean apt cache
apt-get clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment