PhyrePanel-mirror/installers/ubuntu-20.04/install.sh

152 lines
4.7 KiB
Bash
Raw Normal View History

2024-04-28 15:56:34 +00:00
#!/bin/bash
2024-04-22 11:14:05 +00:00
INSTALL_DIR="/phyre/install"
apt-get update && apt-get install ca-certificates
mkdir -p $INSTALL_DIR
cd $INSTALL_DIR
DEPENDENCIES_LIST=(
"openssl"
"jq"
"curl"
"wget"
"unzip"
"zip"
"tar"
"mysql-common"
"mysql-server"
"mysql-client"
"lsb-release"
"gnupg2"
"ca-certificates"
"apt-transport-https"
"software-properties-common"
"supervisor"
"libonig-dev"
"libzip-dev"
"libcurl4-openssl-dev"
"libsodium23"
"libpq5"
"libssl-dev"
"zlib1g-dev"
)
# Check if the dependencies are installed
for DEPENDENCY in "${DEPENDENCIES_LIST[@]}"; do
2024-05-14 22:30:35 +00:00
apt install -yq $DEPENDENCY
2024-04-22 11:14:05 +00:00
done
# Start MySQL
service mysql start
2024-04-22 11:40:08 +00:00
wget https://raw.githubusercontent.com/PhyreApps/PhyrePanel/main/installers/ubuntu-20.04/greeting.sh
2024-04-22 11:14:05 +00:00
mv greeting.sh /etc/profile.d/phyre-greeting.sh
# Install PHYRE PHP
2024-04-22 11:40:08 +00:00
wget https://github.com/PhyreApps/PhyrePanelPHP/raw/main/compilators/debian/php/dist/phyre-php-8.2.0-ubuntu-20.04.deb
2024-04-22 11:14:05 +00:00
dpkg -i phyre-php-8.2.0-ubuntu-20.04.deb
# Install PHYRE NGINX
2024-04-22 11:40:08 +00:00
wget https://github.com/PhyreApps/PhyrePanelNGINX/raw/main/compilators/debian/nginx/dist/phyre-nginx-1.24.0-ubuntu-20.04.deb
2024-04-22 11:14:05 +00:00
dpkg -i phyre-nginx-1.24.0-ubuntu-20.04.deb
service phyre start
PHYRE_PHP=/usr/local/phyre/php/bin/php
ln -s $PHYRE_PHP /usr/bin/phyre-php
2024-04-28 15:56:34 +00:00
#!/bin/bash
2024-04-28 15:33:36 +00:00
HOSTNAME=$(hostname)
IP_ADDRESS=$(hostname -I | cut -d " " -f 1)
2024-04-28 15:22:31 +00:00
2024-04-28 15:33:36 +00:00
DISTRO_VERSION=$(cat /etc/os-release | grep -w "VERSION_ID" | cut -d "=" -f 2)
DISTRO_VERSION=${DISTRO_VERSION//\"/} # Remove quotes from version string
DISTRO_NAME=$(cat /etc/os-release | grep -w "NAME" | cut -d "=" -f 2)
DISTRO_NAME=${DISTRO_NAME//\"/} # Remove quotes from name string
2024-04-28 15:40:29 +00:00
LOG_JSON='{"os": "'$DISTRO_NAME-$DISTRO_VERSION'", "host_name": "'$HOSTNAME'", "ip": "'$IP_ADDRESS'"}'
2024-04-28 15:33:36 +00:00
2024-04-28 15:40:29 +00:00
curl -s https://phyrepanel.com/api/phyre-installation-log -X POST -H "Content-Type: application/json" -d "$LOG_JSON"
2024-04-28 15:56:34 +00:00
#!/bin/bash
2024-04-22 11:40:08 +00:00
wget https://github.com/PhyreApps/PhyrePanelWebCompiledVersions/raw/main/phyre-web-panel.zip
2024-04-22 11:14:05 +00:00
unzip -qq -o phyre-web-panel.zip -d /usr/local/phyre/web
rm -rf phyre-web-panel.zip
chmod 711 /home
chmod -R 750 /usr/local/phyre
2024-04-28 15:56:34 +00:00
#!/bin/bash
2024-04-22 11:14:05 +00:00
# Check dir exists
if [ ! -d "/usr/local/phyre/web" ]; then
echo "PhyrePanel directory not found."
return 1
fi
# Go to web directory
cd /usr/local/phyre/web
# Create MySQL user
MYSQL_PHYRE_ROOT_USERNAME="phyre"
MYSQL_PHYRE_ROOT_PASSWORD="$(tr -dc a-za-z0-9 </dev/urandom | head -c 32; echo)"
mysql -uroot -proot <<MYSQL_SCRIPT
CREATE USER '$MYSQL_PHYRE_ROOT_USERNAME'@'%' IDENTIFIED BY '$MYSQL_PHYRE_ROOT_PASSWORD';
GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_PHYRE_ROOT_USERNAME'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
MYSQL_SCRIPT
# Create database
2024-04-24 20:26:49 +00:00
PHYRE_PANEL_DB_PASSWORD="$(tr -dc a-za-z0-9 </dev/urandom | head -c 32; echo)"
PHYRE_PANEL_DB_NAME="phyre$(tr -dc a-za-z0-9 </dev/urandom | head -c 13; echo)"
PHYRE_PANEL_DB_USER="phyre$(tr -dc a-za-z0-9 </dev/urandom | head -c 13; echo)"
2024-04-22 11:14:05 +00:00
mysql -uroot -proot <<MYSQL_SCRIPT
2024-04-24 20:26:49 +00:00
CREATE DATABASE $PHYRE_PANEL_DB_NAME;
CREATE USER '$PHYRE_PANEL_DB_USER'@'localhost' IDENTIFIED BY '$PHYRE_PANEL_DB_PASSWORD';
GRANT ALL PRIVILEGES ON $PHYRE_PANEL_DB_NAME.* TO '$PHYRE_PANEL_DB_USER'@'localhost';
2024-04-22 11:14:05 +00:00
FLUSH PRIVILEGES;
MYSQL_SCRIPT
mysql_secure_installation --use-default
# Change mysql root password
MYSQL_ROOT_PASSWORD="$(tr -dc a-za-z0-9 </dev/urandom | head -c 32; echo)"
mysql -uroot -proot <<MYSQL_SCRIPT
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '$MYSQL_ROOT_PASSWORD';
FLUSH PRIVILEGES;
MYSQL_SCRIPT
# Save mysql root password
2024-04-24 20:26:49 +00:00
echo "$MYSQL_ROOT_PASSWORD" > /root/.mysql_root_password
2024-04-22 11:14:05 +00:00
# Configure the application
2024-05-10 16:37:15 +00:00
phyre-php artisan phyre:set-ini-settings APP_ENV "local"
2024-05-10 16:31:28 +00:00
phyre-php artisan phyre:set-ini-settings APP_URL "127.0.0.1:8443"
phyre-php artisan phyre:set-ini-settings APP_NAME "PHYRE_PANEL"
phyre-php artisan phyre:set-ini-settings DB_DATABASE "$PHYRE_PANEL_DB_NAME"
phyre-php artisan phyre:set-ini-settings DB_USERNAME "$PHYRE_PANEL_DB_USER"
phyre-php artisan phyre:set-ini-settings DB_PASSWORD "$PHYRE_PANEL_DB_PASSWORD"
phyre-php artisan phyre:set-ini-settings DB_CONNECTION "mysql"
phyre-php artisan phyre:set-ini-settings MYSQL_ROOT_USERNAME "$MYSQL_PHYRE_ROOT_USERNAME"
phyre-php artisan phyre:set-ini-settings MYSQL_ROOT_PASSWORD "$MYSQL_PHYRE_ROOT_PASSWORD"
phyre-php artisan phyre:key-generate
2024-04-22 11:14:05 +00:00
phyre-php artisan migrate
phyre-php artisan db:seed
2024-05-10 16:37:15 +00:00
phyre-php artisan phyre:set-ini-settings APP_ENV "production"
2024-04-22 11:14:05 +00:00
chmod -R o+w /usr/local/phyre/web/storage/
chmod -R o+w /usr/local/phyre/web/bootstrap/cache/
2024-05-16 20:05:51 +00:00
CURRENT_IP=$(hostname -I | awk '{print $1}')
2024-04-22 11:14:05 +00:00
echo "PhyrePanel downloaded successfully."
echo "Please visit http://$CURRENT_IP:8443 to continue installation of the panel."