作者:超人懒懒_673 | 来源:互联网 | 2023-09-25 13:41
本文由编程笔记#小编为大家整理,主要介绍了sh 使用shell脚本和make文件的新站点设置相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env drush php-script --everything -v
// ---------------------------------------
// CREDENTIALS ETC.
// ---------------------------------------
$dir = "public_html";
$theme_dir = "public_html/sites/all/themes";
$makefile = "site.make";
$db_user = "";
$db_pass = "";
$db_name = "";
$site_name = "My Awesome Website";
$shortname = "awesome";
$account_name = "admin";
$account_pass = "Password123";
$account_email = "webmaster@yourname.com";
/*---------------------------------------
MODULES AND FEATURES
Enter the features and modules you
want to install
---------------------------------------*/
$modules = "views views_ui context context_ui features admin_menu block_class re_social_media google_analytics webform jquery_update libraries oembed print menu_breadcrumb backup_migrate";
$features = "re_wysiwyg_profile re_roles re_events re_slideshow re_page re_news rubik cogito $shortname";
$modules_dis = "overlay toolbar"; //Disable these
/*---------------------------------------
* That's it. That's all you need to do.
*
* BELOW HERE IS THE MAGIC
*
*
---------------------------------------*/
/*---------------------------------------
COMMAND DEFINITIONS
Defined commands that will be run later.
----------------------------------------*/
$build_cmd = "drush make -v $makefile $dir";
$site_install_cmd = "drush site-install standard --account-name=%s --account-pass=%s --account-mail=%s --site-name=%s --db-url=mysql://%s:%s@localhost/%s -y";
$module_enable_cmd = "drush en $modules -y";
$module_dis_cmd = "drush dis $modules_dis -y";
$feature_enable_cmd = "drush pm-enable $features -y";
$new_child_theme_cmd = "cp -fr cogito/STARTER_CHILD ./$shortname; mv $shortname/STARTER_CHILD.info $shortname/$shortname.info; mv $shortname/STARTER_CHILD.css $shortname/$shortname.css; sed -i.bak 's/^name.*/name = $site_name Theme/g' $shortname/$shortname.info; sed -i.bak 's/STARTER_THEME/$shortname/g' $shortname/$shortname.info;";
$set_themes_cmd = "drush vset theme_default $shortname -y; drush vset admin_theme rubik -y";
$cron_cmd = 'drush cron -y';
$cc = 'drush cc all -y';
drush_print('------------------------------------------');
drush_print("START THE BUILD!");
drush_print("you could sit here watching this or you ");
drush_print("could go find something more fun to do. ");
drush_print("");
drush_print("... when was the last time you stretched?");
drush_print('------------------------------------------');
//drush_print( "The arguments to this command were" );
//drush_print( print_r(drush_get_arguments() ) );
//drush_print('------------------------------------------');
/*---------------------------------------
Run the drush make command
---------------------------------------*/
if ( drush_shell_exec($build_cmd) ){
drush_log('RE -- Drush Make Succeeded', 'ok');
}
else{
drush_shell_exec_output();
drush_log('RE -- drush make FAILED', 'error');
exit(0);
}
/*---------------------------------------
Now do a site install
---------------------------------------*/
if (drush_shell_cd_and_exec($dir, $site_install_cmd, $account_name, $account_pass, $account_email, $site_name, $db_user, $db_pass, $db_name, $site_name )) {
drush_log('RE -- Install Succeeded', 'ok');
}
else{
drush_shell_exec_output();
drush_log('RE -- Install FAILED', 'error');
exit(0);
}
/*---------------------------------------
Now Disable the modules
---------------------------------------*/
if (drush_shell_cd_and_exec($dir, $module_dis_cmd )) {
drush_shell_exec_output();
drush_log('RE -- Module DISABLE Succeeded', 'ok');
}
else{
drush_shell_exec_output();
drush_log('RE -- Module DISABLE FAILED', 'error');
exit(0);
}
/*---------------------------------------
Now Enable the modules
---------------------------------------*/
if (drush_shell_cd_and_exec($dir, $module_enable_cmd )) {
drush_shell_exec_output();
drush_log('RE -- Module Enable Succeeded', 'ok');
}
else{
drush_shell_exec_output();
drush_log('RE -- Module Enable FAILED', 'error');
exit(0);
}
/*---------------------------------------
Now set Up a new child theme
---------------------------------------*/
if (drush_shell_cd_and_exec($theme_dir, $new_child_theme_cmd )) {
drush_shell_exec_output();
drush_log('RE -- CHILD themes set up Succeeded', 'ok');
}
else{
drush_shell_exec_output();
drush_log('RE -- CHILD THEME set up FAILED', 'error');
exit(0);
}
/*---------------------------------------
Now Enable the FEATURES and themes
---------------------------------------*/
if (drush_shell_cd_and_exec($dir, $feature_enable_cmd )) {
drush_shell_exec_output();
drush_log('RE -- Feature Enable Succeeded', 'ok');
}
else{
drush_shell_exec_output();
drush_log('RE -- Feature Enable FAILED', 'error');
exit(0);
}
/*---------------------------------------
Now set the admin and default themes
---------------------------------------*/
if (drush_shell_cd_and_exec($dir, $set_themes_cmd )) {
drush_shell_exec_output();
drush_log('RE -- Default themes set up Succeeded', 'ok');
}
else{
drush_shell_exec_output();
drush_log('RE -- Theme set up FAILED', 'error');
exit(0);
}
/*---------------------------------------
Now do a cron
---------------------------------------*/
if (drush_shell_cd_and_exec($dir, $cron_cmd) ) {
drush_log('RE -- Cron Succeeded', 'ok');
}
else{
drush_shell_exec_output();
drush_log('RE -- Cron FAILED', 'error');
exit(0);
}
/*---------------------------------------
// Now clear the cash
---------------------------------------*/
if (drush_shell_cd_and_exec($dir, $cc) ) {
drush_log('RE -- Cache cleared Successfully', 'ok');
}
else{
drush_shell_exec_output();
drush_log('RE -- Cache clear FAILED', 'error');
exit(0);
}