install.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. echo "Installing Composer..."
  17. wget https://getcomposer.org/installer -O composer.phar
  18. php composer.phar
  19. php composer.phar install --no-dev
  20. echo "Writing configuration..."
  21. sed -i -e "s/$_ENV['key'] = 'ChangeMe';/$_ENV['key'] = '$key';/g" \
  22. -e "s/$_ENV['appName'] = 'SSPanel-UIM';/$_ENV['appName'] = '$app_name';/g" \
  23. -e "s|$_ENV['baseUrl'] = 'https://example.com';|$_ENV['baseUrl'] = '$base_url';|g" \
  24. -e "s/$_ENV['muKey'] = 'SSPanel';/$_ENV['muKey'] = '$mu_key';/g" \
  25. -e "s/$_ENV['db_host'] = '';/$_ENV['db_host'] = '$db_host';/g" \
  26. -e "s/$_ENV['db_database'] = 'sspanel';/$_ENV['db_database'] = '$db_database';/g" \
  27. -e "s/$_ENV['db_username'] = 'root';/$_ENV['db_username'] = '$db_username';/g" \
  28. -e "s/$_ENV['db_password'] = 'sspanel';/$_ENV['db_password'] = '$db_password';/g" \
  29. config/.config.php
  30. echo "Creating database and user..."
  31. mysql -uroot -p $db_root_password \
  32. -e "CREATE DATABASE $db_database CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  33. CREATE USER '$db_username'@'localhost';
  34. GRANT ALL PRIVILEGES ON $db_database.* TO '$db_username'@'localhost' IDENTIFIED BY '$db_password';
  35. FLUSH PRIVILEGES;"
  36. echo "Importing config to database..."
  37. php xcat Migration new
  38. php xcat Tool importAllSettings
  39. current_dir=$(pwd)
  40. crontab -l > cron.tmp
  41. echo "*/5 * * * * /usr/bin/php $current_dir/xcat Cron" >> cron.tmp
  42. crontab cron.tmp
  43. rm cron.tmp
  44. echo "Updating File Permission..."
  45. chmod 755 -R *
  46. chown www -R *
  47. echo "Installation completed! Now you can create your first admin user by running 'php xcat createAdmin'."
  48. }
  49. do_install_sspanel