Автоустановка Modx (и Wordpress) в панеле VestaCP

Решение немного топорное, т.к. устанавливает Modx(Wordpress) при создании домена без уведомлений и возможности отказаться. И в то же время простое, т.к. просто инкюдится скрипт. Если кто решит вопрос с опцией, буду благодарен.
Собрано из кусков сторонних скриптов Василия и с форума VestaCP

Скрипты панели хранятся в $VESTA/bin/
1. Создаём файл v-add-modx
# Adding php wrapper
user="$1"
domain="$2"
ip="$3"
home_dir="$4"
docroot="$5"
modx_link="http://modx.com/download/latest/"
modx_path="/home/$user/web/$domain/public_html"
modx_file="$modx_path/modx.zip"
modx_password=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 9 | head -n 1)
modx_database=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)
modx_database_user=$user"_"$modx_database
cd $home_dir
wget $modx_link -O $modx_file
unzip $modx_file -d $modx_path
mv $modx_path/modx-2.3.2-pl/* $modx_path
rm modx_file
rm -rf $modx_path/modx-2.3.2-pl/ $modx_path/index.html

$VESTA/bin/v-add-database $user $modx_database $modx_database $modx_password
echo "<modx>
<database_type>mysql</database_type>
<database_server>localhost</database_server>
<database>$user"_"$modx_database</database>
<database_user>$user"_"$modx_database</database_user>
<database_password>$modx_password</database_password>
<database_connection_charset>utf8</database_connection_charset>
<database_charset>utf8</database_charset>
<database_collation>utf8_unicode_ci</database_collation>
<table_prefix>modx_</table_prefix>
<https_port>443</https_port>
<http_host>$domain</http_host>
<cache_disabled>0</cache_disabled>
<inplace>1</inplace>
<unpacked>0</unpacked>
<language>ru</language>
<cmsadmin>admin</cmsadmin>
<cmspassword>admin</cmspassword>
<cmsadminemail>admin@$domain</cmsadminemail>
<core_path>/home/$user/web/$domain/public_html/core/</core_path>
<context_mgr_path>/home/$user/web/$domain/public_html/manager/</context_mgr_path>
<context_mgr_url>/manager/</context_mgr_url>
<context_connectors_path>/home/$user/web/$domain/public_html/connectors/</context_connectors_path>
<context_connectors_url>/connectors/</context_connectors_url>
<context_web_path>/home/$user/web/$domain/public_html/</context_web_path>
<context_web_url>/</context_web_url>
<remove_setup_directory>1</remove_setup_directory>
</modx>" > /home/$user/web/$domain/public_html/config.xml

php /home/$user/web/$domain/public_html/setup/index.php --installmode=new --config=/home/$user/web/$domain/public_html/config.xml
chown -R $user:$user /home/$user/web
2. Права на исполнение chmod +x $VESTA/bin/v-add-modx
3. Подключение скрипта. В файле $VESTA/bin/v-add-web-domain после # Logging добавить строку
source $VESTA/bin/v-add-modx
При создании домена установится Modx с логином/паролем admin
Аналогично для Wordpress v-add-wordpress
#!/bin/bash
# Adding php wrapper
user="$1"
domain="$2"
ip="$3"
home_dir="$4"
docroot="$5"
wp_link="http://ru.wordpress.org/latest-ru_RU.zip"
wp_path="/home/$user/web/$domain/public_html"
wp_file="$wp_path/wordpress.zip"
wp_password=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 9 | head -n 1)
wp_database=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)
wp_database_user=$user"_"$wp_database
cd $home_dir
wget $wp_link -O $wp_file
unzip $wp_file -d $wp_path
mv $wp_path/wordpress/* $wp_path
rm $wp_file
rm -rf $wp_path/wordpress/ $wp_path/index.html

chown -R $user:$user /home/$user/web
$VESTA/bin/v-add-database $user $wp_database $wp_database $wp_password
cp $wp_path/wp-config-sample.php $wp_path/wp-config.php
perl -pi -e "s/database_name_here/$user"_"$wp_database/g" $wp_path/wp-config.php
perl -pi -e "s/username_here/$wp_database_user/g" $wp_path/wp-config.php
perl -pi -e "s/password_here/$wp_password/g" $wp_path/wp-config.php
Если кто сможет сделать опцию при добалению домена, буду благодарен.
Alexander V
13 декабря 2014, 04:18
modx.pro
5
3 283
+2

Комментарии: 7

Aртур Чикин
13 декабря 2014, 07:22
0
На счет опции инклюда лучше обратиться на форум весты, там подскажут как сделать это более правильно.
    Alexander V
    13 декабря 2014, 07:24
    0
    Согласен, я туда изначально обратился, правда совсем недавно.
      TITAN-UZ
      15 декабря 2014, 19:55
      0
      Как настроили кэш?
        Alexander V
        16 декабря 2014, 04:05
        0
        Не понял вопрос.
    Илья
    06 апреля 2015, 15:09
    0
    Почему-то не удается воспользоваться вашим скриптом, при создании получаю 504 Gateway Time-out ((

    Папка с доменом создается, также как и без скрипта
      Илья
      06 апреля 2015, 16:01
      0
      Решил сделать немного поэксперементировать, после создания домена просто запускать этот скрипт через ssh, все проходит хорошо
        Alexander V
        06 апреля 2015, 19:45
        0
        Не хватает времени, т.к. архив долго качается. Лучше разместить файлы локально и копировать.
        Через ssh можно создавать и удалять домены. Скрипты в $VESTA/bin
      Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
      7