PhyrePanel-mirror/docker/docker-entrypoint.sh

148 lines
3.9 KiB
Bash
Raw Normal View History

2024-04-22 11:14:05 +00:00
#!/bin/bash
service phyre start
apt-get update && apt-get install -y wget dos2unix
#
#apt-get install libsodium-dev -y
#
2024-04-22 11:40:08 +00:00
#wget https://raw.githubusercontent.com/PhyreApps/PhyrePanel/main/installers/install.sh && chmod +x install.sh && ./install.sh
2024-04-22 11:14:05 +00:00
#
#ls -la
#curl http://localhost:8443
#tail -f /dev/null
#chmod +x /usr/local/phyre/installers/Ubuntu/22.04/install.sh
#dos2unix /usr/local/phyre/installers/Ubuntu/22.04/install.sh
#bash +x /usr/local/phyre/installers/Ubuntu/22.04/install.sh
INSTALL_DIR="/phyre/install"
apt-get update && apt-get install ca-certificates
mkdir -p $INSTALL_DIR
cd $INSTALL_DIR
DEPENDENCIES_LIST=(
"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"
"libssl-dev"
"zlib1g-dev"
)
# Check if the dependencies are installed
for DEPENDENCY in "${DEPENDENCIES_LIST[@]}"; do
apt install -y $DEPENDENCY
done
# Start MySQL
service mysql start
2024-04-22 11:40:08 +00:00
wget https://raw.githubusercontent.com/PhyreApps/PhyrePanel/main/installers/Ubuntu/22.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/PhyrePanelPHPDist/raw/main/debian/php/dist/phyre-php-8.2.0.deb
2024-04-22 11:14:05 +00:00
dpkg -i phyre-php-8.2.0.deb
# Install PHYRE NGINX
2024-04-22 11:40:08 +00:00
wget https://github.com/PhyreApps/PhyrePanelNginxDist/raw/main/debian/nginx/dist/phyre-nginx-1.24.0.deb
2024-04-22 11:14:05 +00:00
dpkg -i phyre-nginx-1.24.0.deb
service phyre start
PHYRE_PHP=/usr/local/phyre/php/bin/php
ln -s $PHYRE_PHP /usr/bin/phyre-php
chmod 711 /home
chmod -R 750 /usr/local/phyre
# 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
PANEL_DB_PASSWORD="$(tr -dc a-za-z0-9 </dev/urandom | head -c 32; echo)"
PANEL_DB_NAME="phyre$(tr -dc a-za-z0-9 </dev/urandom | head -c 13; echo)"
PANEL_DB_USER="phyre$(tr -dc a-za-z0-9 </dev/urandom | head -c 13; echo)"
mysql -uroot -proot <<MYSQL_SCRIPT
CREATE DATABASE $PANEL_DB_NAME;
CREATE USER '$PANEL_DB_USER'@'localhost' IDENTIFIED BY '$PANEL_DB_PASSWORD';
GRANT ALL PRIVILEGES ON $PANEL_DB_NAME.* TO '$PANEL_DB_USER'@'localhost';
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
echo "$MYSQL_ROOT_PASSWORD" > /root/.phyre_mysql_root_password
# Configure the application
cp .env.example .env
sed -i "s/^APP_URL=.*/APP_URL=http://127.0.0.1:8443/" .env
sed -i "s/^APP_NAME=.*/APP_NAME=PHYRE_PANEL/" .env
sed -i "s/^DB_DATABASE=.*/DB_DATABASE=$PANEL_DB_NAME/" .env
sed -i "s/^DB_USERNAME=.*/DB_USERNAME=$PANEL_DB_USER/" .env
sed -i "s/^DB_PASSWORD=.*/DB_PASSWORD=$PANEL_DB_PASSWORD/" .env
sed -i "s/^DB_CONNECTION=.*/DB_CONNECTION=mysql/" .env
2024-05-02 17:56:10 +00:00
sed -i "s/^MYSQL_ROOT_USERNAME=.*/MYSQL_ROOT_USERNAME=$MYSQL_ROOT_USERNAME/" .env
2024-04-22 11:14:05 +00:00
sed -i "s/^MYSQL_ROOT_PASSWORD=.*/MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD/" .env
phyre-php artisan key:generate
phyre-php artisan migrate
phyre-php artisan db:seed
chmod -R o+w /usr/local/phyre/web/storage/
chmod -R o+w /usr/local/phyre/web/bootstrap/cache/
CURRENT_IP=$(curl -s ipinfo.io/ip)
echo "PhyrePanel downloaded successfully."
echo "Please visit http://$CURRENT_IP:8443 to continue installation of the panel."