Merge branch 'develop' of lab.libreho.st:libre.sh/compose.libre.sh into develop

This commit is contained in:
freechelmi 2020-04-03 16:13:42 +02:00
commit efe02f3977
2 changed files with 75 additions and 12 deletions

View file

@ -1,16 +1,17 @@
#!/bin/bash #!/bin/bash
#Current version of libre.sh to be installed #Current version of libre.sh to be installed
LIBRE_VERSION=1.1 LIBRE_VERSION=develop
# System env vars # System env vars : can be overrided by a values.env file next to this install file
### CONFIG : Specify you template repo ROOT without training slash (Optional) or comment if you want to supply full url for apps
APP_REPO_URL="lab.libreho.st/libre.sh/compose"
## domain handling ## domain handling
### TODO : Specify you template repo ROOT ### CONFIG : change to your domain vendor ( namecheap, ovh , scaleway, )
TEMPLATES_ROOT=lab.libreho.st/libre.sh/compose/
### TODO : change to your domain vendor ( ovh , online, )
DOMAIN_SERVER=namecheap DOMAIN_SERVER=namecheap
### Namecheap specific ### Namecheap specific
@ -18,12 +19,19 @@ NAMECHEAP_URL="namecheap.com"
NAMECHEAP_API_USER="pierreo" NAMECHEAP_API_USER="pierreo"
NAMECHEAP_API_KEY= NAMECHEAP_API_KEY=
### ovh specific ### ovh specific (WIP)
OVH_URL="eu.api.ovh.com" OVH_URL="eu.api.ovh.com"
OVH_API_USER="" OVH_API_USER=""
OVH_API_KEY= OVH_API_KEY=
### Scaleway specific (WIP)
SCALEWAY_URL=""
SCALEWAY_API_USER=""
SCALEWAY_API_KEY=
### TODO : change your settings
IP="curl -s http://icanhazip.com/" IP="curl -s http://icanhazip.com/"
FirstName="Pierre" FirstName="Pierre"
LastName="Ozoux" LastName="Ozoux"
@ -36,16 +44,26 @@ City="Lisbon"
CountryCode="PT" CountryCode="PT"
## Backup ## Backup
BACKUP_DESTINATION=root@xxxxx:port BACKUP_DESTINATION=root@xxxxx:port
### CONFIG : Change your mail settings.
## SMTP ## SMTP
MAIL_USER= MAIL_USER=
MAIL_PASS= MAIL_PASS=
MAIL_HOST=mail.indie.host MAIL_HOST=mail.indie.host
MAIL_PORT=587 MAIL_PORT=587
# Default admin emails for apps
ADMIN_EMAIL=support@ekimia.fr
### TODO : source a setting file is present to override defaults
echo "-------- Welcome to libre.sh $LIBRE_VERSION installer" echo "-------- Welcome to libre.sh $LIBRE_VERSION installer"
echo "---- sourcing local values.env file if present"
source values.env
# STEP add kernel parameter # STEP add kernel parameter
@ -53,6 +71,20 @@ echo "-------- Welcome to libre.sh $LIBRE_VERSION installer"
echo "-------- setting up system variables" echo "-------- setting up system variables"
echo "APP_REPO_URL=${APP_REPO_URL}" >> /etc/environment
echo "LIBRE_VERSION=${LIBRE_VERSION}" >> /etc/environment
echo "MAIL_USER=${MAIL_USER}" >> /etc/environment
echo "MAIL_PASS=${MAIL_PASS}" >> /etc/environment
echo "MAIL_HOST=${MAIL_HOST}" >> /etc/environment
echo "MAIL_PORT=${MAIL_PORT}" >> /etc/environment
echo "ADMIN_EMAIL=${ADMIN_EMAIL}" >> /etc/environment
# STEP Install Docker # STEP Install Docker
@ -98,3 +130,5 @@ cat > /etc/profile.d/libre.sh <<EOF
export PATH=$PATH:/opt/bin export PATH=$PATH:/opt/bin
EOF EOF
chmod 644 /etc/profile.d/libre.sh chmod 644 /etc/profile.d/libre.sh
bash /etc/profile.d/libre.sh

View file

@ -26,11 +26,13 @@ LOG_LEVEL="${LOG_LEVEL:-6}" # 7 = debug -> 0 = emergency
# opts & defaults from. The parsing is unforgiving so be precise in your syntax # opts & defaults from. The parsing is unforgiving so be precise in your syntax
read -r -d '' usage <<-'EOF' read -r -d '' usage <<-'EOF'
-u [arg] URL to process. Required. -u [arg] URL to process. Required.
-a [arg] Application to install. (in the form github.com/indiehosters/wordpress) -a [arg] Application to install. (in the form github.com/indiehosters/wordpress or wordpress in REPO_MODE)
-t [arg] Checkout a specific tag or branch from the application repo. default to master
-e [arg] Specify the email of the application admin
-s Start the application right away. -s Start the application right away.
-b Buys the associated domain name. -b Buys the associated domain name.
-i Configure OpenDKIM. -i Configure OpenDKIM.
-c Configures DNS on Namecheap. -c Configures DNS if possible.
-d Enables debug mode -d Enables debug mode
-h This page -h This page
EOF EOF
@ -103,10 +105,34 @@ function buy_domain_name () {
} }
function application () { function application () {
git clone https://${arg_a}.git /data/domains/${arg_u}
#We check if a APP_REPO_URL was specified
if [ -z ${APP_REPO_URL:-} ]; then
warning "NO repo URL specified, using argument as full URL"
git_url=https://${arg_a}.git
else
warning "REPO specified, using argument as app name"
git_url=https://${APP_REPO_URL}/${arg_a}.git
fi
#Define the tag/branch
git clone ${git_url} -b ${arg_t} /data/domains/${arg_u}
cd /data/domains/${arg_u} cd /data/domains/${arg_u}
if [ -f ./scripts/install ]; then if [ -f ./scripts/install ]; then
#domain
export URL=${arg_u} export URL=${arg_u}
#admin email
if [ -z "${arg_e}" ]; then
warning "No admin_email specified with -e , using default hoster email"
else
export ADMIN_EMAIL=${arg_e}
debug " admin email is ${ADMIN_EMAIL} "
fi
if [ -z ${MAIL_DOMAIN:-} ]; then if [ -z ${MAIL_DOMAIN:-} ]; then
warning "you have no email server setup, we'll print a random configuration in your application. Make sure to check the parameters for your app to send proper emails." warning "you have no email server setup, we'll print a random configuration in your application. Make sure to check the parameters for your app to send proper emails."
warning "To stop having this warning, please configure your libre.sh to be abble to create email accounts." warning "To stop having this warning, please configure your libre.sh to be abble to create email accounts."
@ -126,6 +152,7 @@ function application () {
fi fi
} }
function start () { function start () {
systemctl start u@${arg_u} systemctl start u@${arg_u}
systemctl enable u@${arg_u} systemctl enable u@${arg_u}
@ -201,6 +228,8 @@ fi
[ -z "${arg_u}" ] && help "URL is required." [ -z "${arg_u}" ] && help "URL is required."
[ -z "${LOG_LEVEL}" ] && emergency "Cannot continue without LOG_LEVEL." [ -z "${LOG_LEVEL}" ] && emergency "Cannot continue without LOG_LEVEL."
# tags/branch for modules
[ -z "${arg_t}" ] && arg_t=master
### Runtime ### Runtime