Installer
Installer
/usr/bin/env bash
scriptname=$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")
dirInstall="/opt/drmphp"
#################################
# F U N C T I O N S #
#################################
function isRoot() {
if [ $EUID -ne 0 ]; then
return 1
fi
}
function checkRunning() {
runningPid=$(ps -ax|grep -i apache|grep -v grep|grep -v "$scriptname"|awk '{print
$1}')
echo $runningPid
}
function getIP() {
[ -z "`which dig`" ] && serverIP=$(host myip.opendns.com resolver1.opendns.com |
tail -n1 | cut -d' ' -f4-) || serverIP=$(dig +short myip.opendns.com
@resolver1.opendns.com)
# echo $serverIP
}
function checkOS() {
if [[ -e /etc/debian_version ]]; then
OS="debian"
PKGS='git software-properties-common iputils-ping dnsutils apache2 mysql-server
aria2'
source /etc/os-release
if [[ $ID == "debian" ]]; then
if [[ $VERSION_ID -lt 8 ]]; then
echo " Your Debian version is unsupported."
echo ""
echo " Script supports only Debian >=8"
echo ""
exit 1
fi
elif [[ $ID == "ubuntu" ]]; then
OS="ubuntu"
MAJOR_UBUNTU_VERSION=$(echo "$VERSION_ID" | cut -d '.' -f1)
if [[ $MAJOR_UBUNTU_VERSION -lt 18 ]]; then
echo "Your Ubuntu version is unsupported."
echo ""
echo "Script supports only Ubuntu >=18"
echo ""
exit 1
fi
fi
function checkInternet() {
[ -z "`which ping`" ] && echo " First install iputils-ping" && exit 1
echo " Checking Internet access…"
if ! ping -c 2 google.com &> /dev/null; then
echo " - No Internet. Check your network and DNS settings."
exit 1
fi
echo " - Have Internet Access"
}
function initialCheck() {
if ! isRoot; then
echo " Script must run as root or user with sudo privileges. Example: sudo
$scriptname"
exit 1
fi
checkOS
checkArch
checkInternet
}
function installDRMPHP() {
echo " Installing and configuring DRMPHP..."
cp -r "$dirInstall/panel/." /var/www/html;
cd /var/www/html
chmod +x mp4decrypt
[[ ! -d "./download" ]] && mkdir -p "download"
chmod 777 download;
cd ../;
[[ ! -d "./backup" ]] && mkdir -p "backup"
chmod 777 backup;
chmod 777 html;
echo " Panel configured successfully!";
if [ -f /root/.my.cnf ]; then
read -s -p "Please enter root user MySQL password (password will be hidden when
typing): " rootpasswd </dev/tty
else
read -p "Please create root user MySQL password: " rootpasswd </dev/tty
fi
echo "";
read -p "Please enter the NAME of the new MySQL database (example: db1): "
dbname </dev/tty
sed -i "s/drm/$dbname/g" /var/www/html/_db.php
read -p "Please enter the MySQL database CHARACTER SET (enter utf8 if you
don't know what you are doing): " charset </dev/tty
echo "Creating new MySQL database..."
mysql -uroot -p${rootpasswd} -e "CREATE DATABASE ${dbname} /*\!40100 DEFAULT
CHARACTER SET ${charset} */;"
echo "Database successfully created!"
read -p "Please enter the NAME of the new MySQL database user (example: user1):
" username </dev/tty
sed -i "s/admin/$username/g" /var/www/html/_db.php
read -s -p "Please enter the PASSWORD for the new MySQL database user
(password will be hidden when typing): " userpass </dev/tty
sed -i "s/passwd/$userpass/g" /var/www/html/_db.php
echo "Creating new user..."
mysql -uroot -p${rootpasswd} -e "CREATE USER ${username}@localhost IDENTIFIED
BY '${userpass}';"
echo "User successfully created!"
echo ""
echo "Granting ALL privileges on ${dbname} to ${username}!"
mysql -uroot -p${rootpasswd} -e "GRANT ALL PRIVILEGES ON ${dbname}.* TO '$
{username}'@'localhost';"
mysql -uroot -p${rootpasswd} -e "FLUSH PRIVILEGES;"
mysql -uroot -p${rootpasswd} ${dbname} < "$dirInstall/db.sql"
# MySQL commands
commands=$(cat <<EOF
USE $dbname;
SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';
SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION';
EOF
)
echo "$commands" | mysql -u root -p"$rootpasswd"
function cleanup() {
rm -rf $dirInstall;
}
#####################################
# E N D F U N C T I O N S #
#####################################
echo ""
echo "#############################################################"
echo "# DRMPHP install and configuration script for Linux #"
echo "#############################################################"
echo ""
while true; do
echo ""
read -p " This script will install DRMPHP on your system. Continue? (Yes|No) " yn
</dev/tty
case $yn in
[Yy]*)
initialCheck
installDRMPHP
cleanup
break
;;
[Nn]*)
break
;;
*) echo " Enter Yes or No"
;;
esac
done
getIP
echo "####################################################";
echo "# PANEL DETAILS #";
echo "####################################################";
echo "USER: admin";
echo "PASS: Admin@2023##";
echo "URL: http://${serverIP}:${answer_port}/login.php";
echo "----------------------------------------------------";
echo "NOTE: EDIT <M3U8 Download URL> IN SETTINGS PAGE";
echo "";
echo "Have Fun!"
echo ""
sleep 3