#!/bin/bash # install LeTTo and docker on Ubuntu LTS and # configure proxy, mysql, setup # --------------------------------------------------------------------------------------------------------------------- # you can set the all credentials here or leave it blank to read from commandline # password for the user 'admin' in the web-configuration-site # if user letto is previously not installed the password is used for the new user letto password= # Base directory for Server-Installation lettobase=/opt/letto # --------------------------------------------------------------------------------------------------------------------- echo Install LeTTo-Setup echo ubuntu=$(lsb_release -d | grep "Ubuntu" | wc -l) ubuntu1804=$(lsb_release -d | grep "Ubuntu 18.04" | wc -l) ubuntu2004=$(lsb_release -d | grep "Ubuntu 20.04" | wc -l) ubuntu2204=$(lsb_release -d | grep "Ubuntu 22.04" | wc -l) debian=$(lsb_release -d | grep "Debian GNU/Linux" | wc -l) debian11=$(lsb_release -d | grep "Debian GNU/Linux 11" | wc -l) # check if root-rights are available if [ `id -u` = 0 ] ; then echo Install is running as root! echo Installs docker if not installed echo Creates user \"letto\" if not exists echo Configure user \"letto\" to be a docker admin echo install setup-service in Docker-Container on Port 8096-http - please do not open the port to the internet!! echo setup-service will be started from /etc/rc.local echo setup start and stop scripts are located in $lettobase/setup else echo No root rights! Please start setup as root! exit 1 fi if [ $ubuntu -eq 1 ] ; then arch=ubuntu elif [ $debian -eq 1 ] ; then arch=debian else echo please run script only on Ubuntu or Debian or adapt script to your linux-distribution exit 1 fi # commandline-parameters for i in $@ ; do # password if [[ $i == "-p"* ]] ; then password=${i:2} fi done # password for user admin in the setup if [ -z $password ] ; then echo if getent passwd letto >/dev/null ; then echo "Set password for the user 'admin' in the web-configuration-site - No Passwort to cancel installation." else echo "Set password for the linux-user 'letto' and the user 'admin' in the web-configuration-site - No Passwort to cancel installation." fi echo -n password: read -s password echo fi if [ -z $password ] ; then echo Installation cancelled! exit 1 fi # update all apt-get -y update && \ apt-get -y upgrade && \ apt-get -y dist-upgrade && \ apt-get -y autoremove if ! [ $? -eq 0 ] ; then echo "error - install cancelled!"; exit 1; fi echo system is up to date # install packages apt-get install -y apt-utils apt-transport-https software-properties-common && \ apt-get install -y zip less nano unzip wget net-tools gawk && \ apt-get install -y htop iputils-ping dos2unix curl && \ apt-get install -y ca-certificates curl gnupg lsb-release if ! [ $? -eq 0 ] ; then echo "error - install cancelled!"; exit 1; fi echo needed linux-packages installed echo install java 17 jdk if [ $ubuntu -eq 1 ] ; then #apt-get install -y openjdk-8-jre openjdk-8-jdk openjdk-8-demo openjdk-8-doc openjdk-8-jre-headless openjdk-8-source #if ! [ $? -eq 0 ] ; then echo "cannot install java 8 - install cancelled!"; exit 1; fi apt-get install -y openjdk-17-jre openjdk-17-jdk openjdk-17-jre-headless openjdk-17-source if ! [ $? -eq 0 ] ; then echo "cannot install java 17 - install cancelled!"; exit 1; fi elif [ $debian -eq 1 ] ; then #apt install apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common -y && \ #wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | apt-key add - && \ #add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ && \ #apt update && \ #apt install adoptopenjdk-8-hotspot -y #if ! [ $? -eq 0 ] ; then echo "cannot install java 8 - install cancelled!"; exit 1; fi apt install -y apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common apt install -y openjdk-17-jre openjdk-17-jdk openjdk-17-jre-headless openjdk-17-source if ! [ $? -eq 0 ] ; then echo "cannot install java 17 - install cancelled!"; exit 1; fi else if java -version 2>&1 | grep -q "version" ; then echo Java installed else echo please install java JDK greater oder equals Java-17 and rerun script exit 1 fi fi # check if user letto is present and create if not if getent passwd letto >/dev/null; then echo user letto exists else apt-get -y update apt-get -y install openssl /sbin/useradd -rm -d /home/letto -s /bin/bash letto -p "$(openssl passwd -1 $password)" /sbin/adduser --gecos letto,0,0,0 letto if getent passwd letto >/dev/null; then echo user letto correctly installed else echo please create user letto with group letto exit 1 fi fi if getent group letto >/dev/null; then echo group letto exists else /sbin/addgroup letto fi if getent group letto | grep -q "\bletto\b"; then echo letto is in group letto else /sbin/adduser letto letto fi # uid from user letto lettouid=$(id letto | awk '{match($0,"uid=([0-9]+)\\(",a)}END{print a[1]}') # check and install docker curl -fsSL https://download.docker.com/linux/$arch/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/$arch $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list >/dev/null && \ apt-get -y update && \ apt-get -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin if ! [ $? -eq 0 ] ; then echo "error - install cancelled!"; exit 1; fi if docker version | grep -q Docker; then echo docker installed else echo please install docker echo script cancelled! exit 1 fi # check and install docker compose dockercompose= if docker compose version 2>>/dev/null | grep -q "Docker Compose"; then echo docker compose is installed dockercompose="docker compose" else apt-get -y install docker-compose-plugin if docker compose version 2>>/dev/null | grep -q "Docker Compose"; then echo docker compose is installed dockercompose="docker compose" fi fi if [ -z $dockercompose ] ; then echo please install docker compose plugin echo script cancelled! exit 1 fi # add user letto to docker group if getent group docker | grep -q "\bletto\b"; then echo letto is in group docker else /sbin/adduser letto docker fi # create paths echo create paths mkdir $lettobase -p mkdir $lettobase/setup -p mkdir $lettobase/docker -p mkdir $lettobase/docker/compose -p mkdir $lettobase/docker/compose/setup -p mkdir $lettobase/docker/compose/letto -p mkdir $lettobase/docker/compose/mysql -p mkdir $lettobase/docker/proxy -p mkdir $lettobase/docker/public -p mkdir $lettobase/docker/storage -p mkdir $lettobase/docker/storage/database -p mkdir $lettobase/docker/storage/database-dump -p mkdir $lettobase/docker/storage/database-backup -p mkdir $lettobase/docker/storage/images -p mkdir $lettobase/docker/storage/photos -p mkdir $lettobase/docker/storage/plugins -p mkdir $lettobase/docker/storage/projekte -p mkdir $lettobase/docker/storage/print -p mkdir $lettobase/docker/storage/export -p mkdir $lettobase/docker/storage/backup -p mkdir $lettobase/docker/storage/log -p mkdir $lettobase/docker/storage/log/letto -p mkdir $lettobase/docker/storage/log/data -p # create standard startpage in public echo "" >$lettobase/docker/public/index.html echo "" >>$lettobase/docker/public/index.html echo "
" >>$lettobase/docker/public/index.html echo " " >>$lettobase/docker/public/index.html echo "