#!/bin/bash set -e # # Froxlor for Linux installation script # # !!! EXPERIMENTAL VERSION AHEAD !!! # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # # This script is meant for quick & easy install via: # $ curl -fsSL https://get.froxlor.dev | sudo bash # SCRIPT_VERSION="develop" 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 # # The main installation script # do_install() { # Root Check if [ "$EUID" -ne 0 ]; then alert "Please run as root (e.g. with sudo)" exit 1 fi # Variables LOG_FILE="/var/log/froxlor-install.log" INSTALL_DIR="/opt/froxlor" COMPOSE_FILE="$INSTALL_DIR/docker-compose.yml" ENV_FILE="$INSTALL_DIR/froxlor.env" mkdir -p /var/log touch "$LOG_FILE" # Logging exec > >(tee -a "$LOG_FILE") 2>&1 intro echo step "Installation started at $(date)" # Prerequisites step "Checking prerequisites" export DEBIAN_FRONTEND=noninteractive # Server IP while [[ -z $serveripv4 ]]; do serveripv4="$(curl -fsSL4 https://get.froxlor.org/ip.php)" if [[ $noninteractive == 0 ]]; then read -r -e -p " Enter the public server IPv4: " -i "$serveripv4" serveripv4 /dev/null; then run_with_spinner "Installing Docker" bash -c "curl -fsSL https://get.docker.com | sh >>\"$LOG_FILE\" 2>&1" else step "Docker already installed" fi # Create directory step "Create directory $INSTALL_DIR" mkdir -p "$INSTALL_DIR" # Environment file if [ ! -f "$ENV_FILE" ]; then step "Create froxlor environment file $ENV_FILE" MYSQL_PASSWORD=$(openssl rand -base64 16) cat > "$ENV_FILE" </dev/null; do printf "\b%s" "${spinner[i]}" i=$(( (i+1) % 4 )) sleep 0.1 done wait "$pid" local status=$? # Finish line if [ $status -eq 0 ]; then printf "\b${green}Done!${normal}\n" step "$msg completed" else printf "\b${red}Error!${normal}\n" echo "${red}Command failed: ${cmd[*]}${normal}" exit $status fi } 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 environment variables are stored in: ${2}${normal}" echo -e " ${bold}${green}Log file is stored in: ${3}${normal}" echo echo -e " ${bold}${green}You can enter http://${4}:8000 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