install.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 "Writting configuration..."
  22. sed -i -e "s/$_ENV['key'] = 'ChangeMe';/$_ENV['key'] = '$key';/g" \
  23. -e "s/$_ENV['appName'] = 'SSPanel-UIM';/$_ENV['appName'] = '$app_name';/g" \
  24. -e "s|$_ENV['baseUrl'] = 'https://example.com';|$_ENV['baseUrl'] = '$base_url';|g" \
  25. -e "s/$_ENV['muKey'] = 'SSPanel';/$_ENV['muKey'] = '$mu_key';/g" \
  26. -e "s/$_ENV['db_host'] = '';/$_ENV['db_host'] = '$db_host';/g" \
  27. -e "s/$_ENV['db_database'] = 'sspanel';/$_ENV['db_database'] = '$db_database';/g" \
  28. -e "s/$_ENV['db_username'] = 'root';/$_ENV['db_username'] = '$db_username';/g" \
  29. -e "s/$_ENV['db_password'] = 'sspanel';/$_ENV['db_password'] = '$db_password';/g" \
  30. config/.config.php
  31. echo "Creating database and user..."
  32. mysql -uroot -p$db_root_password \
  33. -e "CREATE DATABASE $db_database CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  34. CREATE USER '$db_username'@'localhost';
  35. GRANT ALL PRIVILEGES ON $db_database.* TO '$db_username'@'localhost' IDENTIFIED BY '$db_password';
  36. FLUSH PRIVILEGES;"
  37. echo "Importing config to database..."
  38. php vendor/bin/phinx migrate
  39. php xcat Tool importAllSettings
  40. wget https://cdn.jsdelivr.net/gh/sspanel-uim/qqwry.dat@latest/qqwry.dat -O storage/qqwry.dat
  41. current_dir=$(pwd)
  42. crontab -l > cron.tmp
  43. echo "*/1 * * * * /usr/bin/php $current_dir/xcat Job CheckJob" >> cron.tmp
  44. echo "0 */1 * * * /usr/bin/php $current_dir/xcat Job UserJob" >> cron.tmp
  45. echo "0 0 * * * /usr/bin/php -n $current_dir/xcat Job DailyJob" >> cron.tmp
  46. crontab cron.tmp
  47. rm cron.tmp
  48. echo "Updating File Permission..."
  49. chmod 755 -R *
  50. chown www -R *
  51. echo "Installation completed! Now you can create your first admin user by running 'php xcat createAdmin'."
  52. }
  53. do_install_sspanel