#!/bin/bash set -e # Froxlor for Linux installation script # # This script is meant for quick & easy install via: # $ curl -fsSL https://get.froxlor.org | bash # or # $ curl -fsSL https://get.froxlor.org | bash -s -- --unattended # # For development version install via: # $ curl -fsSL https://get.froxlor.org/dev | bash # # More info is available on docs.froxlor.org # https://docs.froxlor.org/latest/general/quick-start-guide/ # SCRIPT_VERSION="2de466b" source /etc/os-release # test if the terminal supports colors if test -t 1; then ncolors=$(which tput >/dev/null && tput colors) if test -n "$ncolors" && test "$ncolors" -ge 8; then termcols=$(tput cols) bold="$(tput bold)" underline="$(tput smul)" standout="$(tput smso)" normal="$(tput sgr0)" black="$(tput setaf 0)" red="$(tput setaf 1)" green="$(tput setaf 2)" yellow="$(tput setaf 3)" blue="$(tput setaf 4)" magenta="$(tput setaf 5)" cyan="$(tput setaf 6)" white="$(tput setaf 7)" fi fi # set default values log="/tmp/froxlor.log" noninteractive=0 webserver="apache24" mysql="default-mysql-server" froxlor_directory="/var/www/html/froxlor" # parse command line arguments while [[ $# -gt 0 ]]; do key="$1" case $key in --mysql=*) mysql="${key#*=}" shift ;; --webserver=*) webserver="${key#*=}" shift ;; --hostname=*) servername="${key#*=}" shift ;; --ipv4=*) serveripv4="${key#*=}" shift ;; --ipv6=*) serveripv6="${key#*=}" shift ;; --unattended) noninteractive=1 shift ;; *) # unknown option shift ;; esac done # # The main installation script # do_install() { # cancel if mysql is not mysql and mariadb if [[ $mysql != "default-mysql-server" && $mysql != "mariadb" ]]; then alert "Sorry but $mysql is not supported" "only default-mysql-server and mariadb are supported" exit 1 fi # cancel if webserver is not apache24 and nginx if [[ $webserver != "apache24" && $webserver != "nginx" ]]; then alert "Sorry but $webserver is not supported" "only apache24 and nginx are supported" exit 1 fi # check if the script was already run if [ -d "$froxlor_directory" ] || dpkg -l | grep -q froxlor; then alert "Running this script twice can cause harm, please delete your files" "froxlor directory, $webserver config, froxlor mysql & user" echo read -e -p "Enter ${red}DELETE${normal} to continue: " DELETE >$log 2>&1 apt-get install -y -qq apt-transport-https lsb-release ca-certificates curl gnupg uuid-runtime >>$log 2>&1 step "prepare installation..." while [[ -z $distribution ]]; do if [[ $noninteractive == 0 ]]; then read -r -e -p " Enter the server distribution: " -i "$VERSION_CODENAME" distribution >$log 2>&1 fi if [[ $mysql == "mariadb" ]]; then step "installing mariadb please wait..." apt-get install -y -qq mariadb-server >>$log 2>&1 fi # check if distribution is supported if [[ ! -f /etc/apt/sources.list.d/froxlor.list ]]; then step "adding froxlor repository" if [[ $distribution == "bookworm" || $distribution == "bullseye" ]]; then curl -sSLo /usr/share/keyrings/deb.froxlor.org-froxlor.gpg https://deb.froxlor.org/froxlor.gpg sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.froxlor.org-froxlor.gpg] https://deb.froxlor.org/debian $(lsb_release -sc) main" > /etc/apt/sources.list.d/froxlor.list' elif [[ $distribution == "jammy" || $distribution == "focal" ]]; then curl -sSLo /usr/share/keyrings/deb.froxlor.org-froxlor.gpg https://deb.froxlor.org/froxlor.gpg sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.froxlor.org-froxlor.gpg] https://deb.froxlor.org/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/froxlor.list' else alert "Distribution is not yet supported." "Please open an issue on github if think this is a mistake" exit 1 fi apt-get update -qq >>$log 2>&1 fi # install froxlor if [[ -z $reinstall ]]; then step "installing froxlor please wait..." apt-get install -y -qq froxlor >>$log 2>&1 else step "reinstalling froxlor please wait..." apt-get install --reinstall -y -qq froxlor >>$log 2>&1 fi step "create privileged mysql user..." cat </tmp/froxlor.sql DROP USER IF EXISTS '$mysql_root_user'@'127.0.0.1'; CREATE USER '$mysql_root_user'@'127.0.0.1' IDENTIFIED BY "$mysql_root_pass"; GRANT ALL PRIVILEGES ON *.* TO '$mysql_root_user'@'127.0.0.1' WITH GRANT OPTION; FLUSH PRIVILEGES; EOF mysql -u root /tmp/froxlor-install.json { "mysql_host": "127.0.0.1", "mysql_ssl_ca_file": "", "mysql_ssl_verify_server_certificate": "0", "mysql_root_user": "$mysql_root_user", "mysql_root_pass": "$mysql_root_pass", "mysql_unprivileged_user": "froxlor", "mysql_unprivileged_pass": "$mysql_unprivileged_pass", "mysql_mysql": "froxlor", "mysql_force_create": "1", "admin_name": "Administrator", "admin_user": "admin", "admin_pass": "$admin_pass", "admin_pass_confirm": "$admin_pass", "admin_email": "$admin_email", "distribution": "$distribution", "serveripv4": "$serveripv4", "serveripv6": "$serveripv6", "servername": "$servername", "use_ssl": "1", "webserver": "$webserver", "webserver_backend": "php-fpm", "httpuser": "www-data", "httpgroup": "www-data", "activate_newsfeed": "1" } EOF if /var/www/html/froxlor/bin/froxlor-cli froxlor:install /tmp/froxlor-install.json -n >>$log 2>&1 ; then finish "$mysql_root_user" "$mysql_root_pass" "$mysql_unprivileged_pass" "$admin_pass" "$serveripv4" else alert "froxlor post-install script failed" "please check $log for more information" exit 1 fi echo } # # Helper functions # step() { printf "${green}\r [i] ${normal}${1}${normal}" echo } intro() { echo echo "${green}================================================================================${normal}" echo -e " ${bold}${green} __ _ ${normal}" echo -e " ${bold}${green} / _|_ __ _____ _| | ___ _ __ ${normal}" echo -e " ${bold}${green}| |_| '__/ _ \ \/ / |/ _ \| '__|${normal}" echo -e " ${bold}${green}| _| | | (_) > <| | (_) | | ${normal}" echo -e " ${bold}${green}|_| |_| \___/_/\_\_|\___/|_| ${normal}" echo echo -e " ${bold}${green}Welcome to the froxlor for Linux installation script ($SCRIPT_VERSION) ${normal}" echo echo -e " We guide you through the installation steps and setup your system :)" echo if [[ $noninteractive == 1 ]]; then echo -e " ${bold}${green}Running in noninteractive mode. ${normal}" echo fi echo "${green}================================================================================${normal}" } alert() { echo echo "${red}================================================================================${normal}" echo echo -e " ${bold}${yellow}${1}${normal}" echo echo -e " ${2}" echo echo "${red}================================================================================${normal}" } section() { echo echo "${white}================================================================================${normal}" echo echo -e " ${bold}${white}${1}${normal}" echo echo "${white}================================================================================${normal}" } finish() { echo echo "${green}================================================================================${normal}" echo echo -e " ${bold}${green}The installation of froxlor was successful! ${normal}" echo echo -e " ${bold}${green}Your admin password is: ${4}${normal}" echo -e " ${bold}${green}Other credentials are stored in: $froxlor_directory/lib/userdata.inc.php${normal}" echo echo -e " ${bold}${green}You can enter http://${5} to access your panel!${normal}" echo echo "${green}================================================================================${normal}" } # # Call the installer at the end of the script, so we make sure all functions # are defined and not got cut off by curl, wget or something else... # do_install