install.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/bash
  2. [ $(id -u) != "0" ] && { echo "Error: You must be root to run this script!"; exit 1; }
  3. do_install_sspanel() {
  4. read -p "Please input root password of your Database server: " db_root_password
  5. read -p "Please input db_host(127.0.0.1): " db_host
  6. read -p "Please input db_database(sspanel): " db_database
  7. read -p "Please input db_username(sspanel): " db_username
  8. read -p "Please input db_password: " db_password
  9. read -p "Please input key: " key
  10. read -p "Please input appName(SSPanel-UIM): " app_name
  11. read -p "Please input baseUrl(https://example.com): " base_url
  12. read -p "Please input muKey(SSPanel): " mu_key
  13. echo "Generating config files..."
  14. cp config/.config.example.php config/.config.php
  15. cp config/appprofile.example.php config/appprofile.php
  16. mv db/migrations/20000101000000_init_database.php.new db/migrations/20000101000000_init_database.php
  17. echo "Installing Composer..."
  18. wget https://getcomposer.org/installer -O composer.phar
  19. php composer.phar
  20. php composer.phar install
  21. echo "Updating File Permission..."
  22. chmod 755 -R *
  23. chown www -R *
  24. echo "Writting configuration..."
  25. sed -i -e "s/$_ENV['key'] = 'ChangeMe';/$_ENV['key'] = '$key';/g" \
  26. -e "s/$_ENV['appName'] = 'SSPanel-UIM';/$_ENV['appName'] = '$app_name';/g" \
  27. -e "s|$_ENV['baseUrl'] = 'https://example.com';|$_ENV['baseUrl'] = '$base_url';|g" \
  28. -e "s/$_ENV['muKey'] = 'SSPanel';/$_ENV['muKey'] = '$mu_key';/g" \
  29. -e "s/$_ENV['db_host'] = '';/$_ENV['db_host'] = '$db_host';/g" \
  30. -e "s/$_ENV['db_database'] = 'sspanel';/$_ENV['db_database'] = '$db_database';/g" \
  31. -e "s/$_ENV['db_username'] = 'root';/$_ENV['db_username'] = '$db_username';/g" \
  32. -e "s/$_ENV['db_password'] = 'sspanel';/$_ENV['db_password'] = '$db_password';/g" \
  33. config/.config.php
  34. echo "Creating database and user..."
  35. mysql -uroot -p$db_root_password \
  36. -e "CREATE DATABASE $db_database CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  37. CREATE USER '$db_username'@'localhost';
  38. GRANT ALL PRIVILEGES ON $db_database.* TO '$db_username'@'localhost' IDENTIFIED BY '$db_password';
  39. FLUSH PRIVILEGES;"
  40. echo "Importing config to database..."
  41. php vendor/bin/phinx migrate
  42. php xcat Tool importAllSettings
  43. php xcat Tool initQQwry
  44. current_dir=$(pwd)
  45. crontab -l > cron.tmp
  46. echo "*/1 * * * * /usr/bin/php $current_dir/xcat Job SendMail" >> cron.tmp
  47. echo "*/1 * * * * /usr/bin/php $current_dir/xcat Job CheckJob" >> cron.tmp
  48. echo "0 */1 * * * /usr/bin/php $current_dir/xcat Job UserJob" >> cron.tmp
  49. echo "30 23 * * * /usr/bin/php $current_dir/xcat SendDiaryMail" >> cron.tmp
  50. echo "0 0 * * * /usr/bin/php -n $current_dir/xcat Job DailyJob" >> cron.tmp
  51. crontab cron.tmp
  52. rm cron.tmp
  53. echo "Installation completed! Now you can create your first admin user by running 'php xcat createAdmin'."
  54. }
  55. do_install_sspanel