Projet

Général

Profil

Paste
Télécharger (3,56 ko) Statistiques
| Branche: | Révision:

root / bin / d7-create-site.sh @ 6c38d829

1 d52a5b2f jenselme
#!/bin/sh
2
3
. /users/guest/assos/bin/scripts-config.sh
4 469b9d6d Julien Enselme
. /users/guest/assos/bin/scripts-config-site.sh $1
5
. /users/guest/assos/bin/scripts-utils.sh
6 d52a5b2f jenselme
7
help="# ARGS: site name"
8
9
######## Exceptions
10
check_arguments $# 1 "$help"
11
12 6d91f38e Julien Enselme
if ! `work_tree_clean` ; then
13 1c1c5a42 Julien Enselme
    echo "Your work tree is not clean. Solve this before $0 can continue."
14
    exit 2
15
fi
16
17 d52a5b2f jenselme
# "-" is forbidden because it provokes database error.
18
if [ `echo $1 | grep -` ] ; then
19
    echo '"-" is forbidden in the site name'
20
    exit 1
21
fi
22
23
# Site name length must be lower or equal to 16 due to database limitations.
24
if [`echo $1 | wc -c` -gt 16 ] ; then
25
    echo "site name can't have more than 16 characters"
26
    exit 1
27
fi
28
29
###### Initialisation
30
cd $d7_dir
31
site_password=`generate_password`
32 ad6711c7 Julien Enselme
site_line_sites_php="\$sites['assos.centrale-marseille.fr.$d7_site_name'] = 'assos.centrale-marseille.fr.$d7_site_name';"
33 364f9fdd Julien Enselme
site_line_aliases_drushrc_php="\$aliases['$d7_site_name'] = array('uri' => 'assos.centrale-marseille.fr/$d7_site_name', 'root' => '/users/guest/assos/htmltest/', );"
34 d52a5b2f jenselme
35
# Check if site database already exists.
36 e0225b3a Julien Enselme
if mysql --defaults-extra-file=$myassos_cnf -e "USE $d7_site_name" 2>/dev/null ; then
37 d52a5b2f jenselme
    echo "Database $d7_site_name already exists"
38
    exit 1
39
fi
40
41
# Check if site folder already exists.
42
if [ -d $d7_site_dir ] ; then
43
    echo "Folder $d7_site_dir already exists"
44
    exit 1
45
fi
46
47
###### Main
48
mkdir $d7_site_dir
49
dir_site_name="assos.centrale-marseille.fr.$d7_site_name"
50
51
# Backup requirements
52
mkdir $d7_dir_individual_auto_backup/$dir_site_name
53
mkdir $d7_dir_individual_manual_backup/$dir_site_name
54
current_date=`date "+%Y-%m-%d-%Hh%Mm%Ss"`
55
56
# NB : ls sort by considering the 1st characters
57
touch $d7_dir_individual_auto_backup/$dir_site_name/$current_date.$dir_site_name.sql
58
touch $d7_dir_individual_auto_backup/$dir_site_name/$current_date.$dir_site_name.sql2
59
touch $d7_dir_individual_auto_backup/$dir_site_name/$current_date.$dir_site_name.sql3
60 ddeedc17 Julien Enselme
touch $d7_dir_individual_auto_backup/$dir_site_name/$current_date.$dir_site_name.sql4
61 d52a5b2f jenselme
62
# Create and grant privileges on database
63 e0225b3a Julien Enselme
mysql --defaults-extra-file=$myassos_cnf -e "CREATE DATABASE $d7_site_name"
64
mysql --defaults-extra-file=$myassos_cnf -e "GRANT ALL PRIVILEGES ON $d7_site_name.* TO '$d7_site_name'@'%' IDENTIFIED BY '$site_password'"
65 d52a5b2f jenselme
66
# Create settings.php
67 469b9d6d Julien Enselme
cp $d7_settings $d7_site_settings
68
generate_settings_local $d7_site_name $site_password $d7_settings_local_template $d7_site_settings_local
69 d52a5b2f jenselme
70
# Create symbolic link
71
cd $d7_dir
72
ln -s . $d7_site_name
73
74 593e9a63 Julien Enselme
# Update sites.php
75 364f9fdd Julien Enselme
chmod +w $sites_php
76 ad6711c7 Julien Enselme
echo $site_line_sites_php >> $sites_php
77 364f9fdd Julien Enselme
chmod 400 $sites_php
78 593e9a63 Julien Enselme
79 0e4152d9 Julien Enselme
### Update aliases.drushrc.php
80
# For site
81
echo $site_line_aliases_drushrc_php >> $aliases_drushrc_php
82
# @d7
83 364f9fdd Julien Enselme
sed s/"'site-list' => array("/"'site-list' => array(%'assos.centrale-marseille.fr\/$d7_site_name',"/ < $aliases_drushrc_php | tr '%' '\n    ' > $dir_tmp/aliases.tmp
84
mv $dir_tmp/aliases.tmp $aliases_drushrc_php
85 0e4152d9 Julien Enselme
86 d52a5b2f jenselme
# Next Instructions
87
echo "Go to http://assos.centrale-marseille.fr/$d7_site_name/install.php to continue."
88
echo "Press enter when ready to go on."
89
read key
90
91
# Init variables
92
d7-reset-variables.sh $d7_site_name
93
94
# Permissions
95
chmod -R 755 $d7_site_dir
96
chmod 400 $d7_site_settings
97
98
# Last instructions
99
echo "Last instructions:"
100
echo "- Advice the webmaster to close account creation on the website"
101
echo "- Give the webmaster a link to the club Drupal's tutorials "
102
echo "- Create a node of type \"Site\" on default"
103
echo "- Register the webmaster on webmasters@listes.centrale-marseille.fr"
104 ad6711c7 Julien Enselme
echo -e "- If line to add to sites.php differs from the line below, please correct it\n\t$site_line_sites_php"
105 1c1c5a42 Julien Enselme
106
commit "Creation of site: $d7_site_name"