#!/bin/sh
set -eu

for i in $(cat /usr/src/nextcloud/config/apps_enable)
    do 
        app=$(echo $i | cut -d '=' -f1)
        version=$(echo $i | cut -d '=' -f2)
        url=$(echo $i | cut -d '=' -f3)
        echo "downloading app $app"
        curl -Ls $url -o $app.tar.gz
        tar xzf $app.tar.gz 
        mv $app /usr/src/nextcloud/custom_apps
        rm $app.tar.gz
    done
    