almost finished, need some tests
This commit is contained in:
parent
3a6dd52445
commit
622a90d12c
8
example.org.conf
Normal file
8
example.org.conf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
ServerAdmin webmaster@example.org
|
||||||
|
ServerName example.org
|
||||||
|
ServerAlias www.example.org
|
||||||
|
DocumentRoot /srv/www/example.org/public_html/
|
||||||
|
ErrorLog /srv/www/example.org/logs/error.log
|
||||||
|
CustomLog /srv/www/example.org/logs/access.log combined
|
||||||
|
</VirtualHost>
|
18
git-post-reveive
Normal file
18
git-post-reveive
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#hook/post-receive
|
||||||
|
#CONFIG
|
||||||
|
|
||||||
|
PRODDIR="www"
|
||||||
|
|
||||||
|
read oldrev newrev refname
|
||||||
|
if [ $refname = "refs/heads/prod" ]; then
|
||||||
|
echo "===== DEPLOYING APP ====="
|
||||||
|
unset GIT_DIR
|
||||||
|
cd ~
|
||||||
|
cd $PRODDIR
|
||||||
|
git pull --ff-only origin prod
|
||||||
|
echo $?
|
||||||
|
echo "====== OK ====="
|
||||||
|
else
|
||||||
|
echo "Warning Commit not deployed, please use prod branch"
|
||||||
|
fi
|
17
git-pre-receive
Normal file
17
git-pre-receive
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#hook/pre-receive
|
||||||
|
#CONFIG
|
||||||
|
PRODDIR="www"
|
||||||
|
|
||||||
|
read oldrev newrev refname
|
||||||
|
if [ $refname = "refs/heads/prod" ]; then
|
||||||
|
echo "===== UPDATE REPOSITORY ====="
|
||||||
|
unset GIT_DIR
|
||||||
|
cd ~
|
||||||
|
cd $PRODDIR
|
||||||
|
git add .
|
||||||
|
git commit -m "Auto Commit"
|
||||||
|
echo "====== OK ====="
|
||||||
|
else
|
||||||
|
echo "Warning Commit not deployed, please use prod branch"
|
||||||
|
fi
|
@ -4,10 +4,13 @@
|
|||||||
# http://www.debian.org/doc/manuals/securing-debian-howto/
|
# http://www.debian.org/doc/manuals/securing-debian-howto/
|
||||||
# https://www.thefanclub.co.za/how-to/how-secure-ubuntu-1204-lts-server-part-1-basics
|
# https://www.thefanclub.co.za/how-to/how-secure-ubuntu-1204-lts-server-part-1-basics
|
||||||
# https://www.linode.com/docs/websites/lamp/lamp-server-on-debian-7-wheezy/
|
# https://www.linode.com/docs/websites/lamp/lamp-server-on-debian-7-wheezy/
|
||||||
|
# http://web-74.com/blog/reseaux/gerer-le-deploiement-facilement-avec-git/
|
||||||
#
|
#
|
||||||
|
|
||||||
echo "This script has been tested only on Linux Debian 7"
|
echo "This script has been tested only on Linux Debian 7"
|
||||||
|
|
||||||
|
_cwd="$(pwd)"
|
||||||
|
|
||||||
echo "Installing harden"
|
echo "Installing harden"
|
||||||
apt-get install harden
|
apt-get install harden
|
||||||
|
|
||||||
@ -59,5 +62,67 @@ chown www-data /var/log/php
|
|||||||
|
|
||||||
apt-get install php5-mysql
|
apt-get install php5-mysql
|
||||||
|
|
||||||
|
echo "installing vhost"
|
||||||
|
read -p "hostname ? " _host_name
|
||||||
|
cp "$_cwd"/example.org.conf /etc/apache2/sites-available/"$_host_name".conf
|
||||||
|
sed -ir "s/example\.org/$_host_name/g" /etc/apache2/sites-available/"$_host_name".conf
|
||||||
|
|
||||||
|
mkdir -p /srv/www/"$_host_name"/public_html
|
||||||
|
mkdir /srv/www/"$_host_name"/logs
|
||||||
|
#set proper right to user will handle the app
|
||||||
|
chown -R root:admin /srv/www/"$_host_name"/
|
||||||
|
chmod -R g+w /srv/www/"$_host_name"/
|
||||||
|
chmod -R g+r /srv/www/"$_host_name"/
|
||||||
|
|
||||||
|
# create a shortcut to the site
|
||||||
|
mkdir /home/"$user"/www/
|
||||||
|
chown "$user":admin /home/"$user"/www/
|
||||||
|
ln -s /srv/www/"$_host_name" /home/"$user"/www/"$_host_name"
|
||||||
|
|
||||||
|
#activate teh vhost
|
||||||
|
a2ensite "$_host_name".conf
|
||||||
|
|
||||||
|
#restart apache
|
||||||
service apache2 restart
|
service apache2 restart
|
||||||
|
|
||||||
|
#installing better prompt and some goodies for root
|
||||||
|
echo "shell prompt"
|
||||||
|
git clone git://github.com/bachy/dotfiles-server.git ~/.dotfiles-server && cd ~/.dotfiles-server && ./install.sh && cd -
|
||||||
|
|
||||||
|
# setup user environment
|
||||||
|
echo "$user tasks"
|
||||||
|
su $user
|
||||||
|
cd ~
|
||||||
|
echo "shell prompt"
|
||||||
|
git clone git://github.com/bachy/dotfiles-server.git ~/.dotfiles-server && cd ~/.dotfiles-server && ./install.sh && cd -
|
||||||
|
cd ~
|
||||||
|
source .bashrc
|
||||||
|
|
||||||
|
# setup bare repositorie to push to
|
||||||
|
echo "setup git repositories"
|
||||||
|
mkdir ~/git-repositories
|
||||||
|
mkdir ~/git-repositories/"$_host_name".git
|
||||||
|
cd ~/git-repositories/"$_host_name".git
|
||||||
|
git init --bare
|
||||||
|
|
||||||
|
# setup git repo on site folder
|
||||||
|
cd /srv/www/"$_host_name"/public_html/
|
||||||
|
git init
|
||||||
|
# link to the bare repo
|
||||||
|
git remote add origin ~/git-repositories/"$_host_name".git
|
||||||
|
|
||||||
|
# cerate hooks that will update the site repo
|
||||||
|
cd ~
|
||||||
|
cp "$_cwd"/pre-receive ~/git-repositories/"$_host_name".git/hooks/
|
||||||
|
cp "$_cwd"/post-receive ~/git-repositories/"$_host_name".git/hooks/
|
||||||
|
|
||||||
|
sed -ir "s/PRODDIR=\"www\"/PRODDIR=\/srv\/www\/$_host_name\/public_html/g" ~/git-repositories/"$_host_name".git/hooks/pre-receive
|
||||||
|
sed -ir "s/PRODDIR=\"www\"/PRODDIR=\/srv\/www\/$_host_name\/public_html/g" ~/git-repositories/"$_host_name".git/hooks/post-receive
|
||||||
|
|
||||||
|
cd ~/git-repositories/"$_host_name".git/hooks/
|
||||||
|
chmod +x post-receive pre-receive
|
||||||
|
|
||||||
|
# done
|
||||||
|
echo "install succeed"
|
||||||
|
echo "your site stay now to ~/www/$_host_name"
|
||||||
|
echo "you can push updates on prod branch throug $user@IP.IP.IP.IP:git-repositories/$_host_name.git"
|
||||||
|
12
readme.md
12
readme.md
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
## how to use it
|
## how to use it
|
||||||
on a fresh install
|
on a fresh install
|
||||||
1 install git
|
1 install git
|
||||||
```
|
```
|
||||||
sudo apt-get git
|
sudo apt-get git
|
||||||
```
|
```
|
||||||
|
|
||||||
2 clone the repo
|
2 clone the repo
|
||||||
```
|
```
|
||||||
@ -23,8 +23,8 @@ chmod a+x install-debian-server.sh
|
|||||||
|
|
||||||
|
|
||||||
## ref
|
## ref
|
||||||
http://www.debian.org/doc/manuals/securing-debian-howto/
|
http://www.debian.org/doc/manuals/securing-debian-howto/
|
||||||
https://www.thefanclub.co.za/how-to/how-secure-ubuntu-1204-lts-server-part-1-basics
|
https://www.thefanclub.co.za/how-to/how-secure-ubuntu-1204-lts-server-part-1-basics
|
||||||
https://www.linode.com/docs/websites/lamp/lamp-server-on-debian-7-wheezy
|
https://www.linode.com/docs/websites/lamp/lamp-server-on-debian-7-wheezy
|
||||||
|
https://www.evernote.com/Home.action#n=28425519-ee9f-4efc-a13b-5426f4b31a78&ses=1&sh=5&sds=5&x=git%2520deploy&
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user