#!/usr/bin/env sh # SPDX-FileCopyrightText: Daniel Pätzold # SPDX-License-Identifier: AGPL-3.0-or-later # # Usage source $(dirname "$0")/setup_system.inc.sh #Lokal Vars LOGFILE="${TEMPDIR}/${SCRIPTNAME}.log" #Check or get Token if [ "${DAVTOKEN_USER}." == "." ]; then get_nc_token fi #Check if encrypted Dir is mounted if [ ${IPAVAULTUSE} == "true" ]; then grep ${DECRYPTEDDATADIR} /etc/mtab >/dev/null if [ $? -ne 0 ]; then echo "Error: IPAVAULTUSE is set to true, but the Directory is not mounted. " echo "Press any key to continue" read -n 1 -s -r echo "" exit 1 fi fi # Use optional Profilename profilename=${3:-"default"} #Parametercheck: if [ "${1}." == "." ]; then echo "ERROR: Parameter 1 missing." BREAK_ERROR=1 elif [ ${1} == 'firefox' ]; then REMOTE_PATH=${PROFILE_FIREFOX_SRC} PROFILE_PATH=${PROFILE_FIREFOX_DST} if [ "${2}." == 'run.' ]; then RUNCMD="/usr/bin/firefox --profile ${PROFILE_FIREFOX_DST}/${profilename}" elif [ "${2}." == 'sync.' ]; then RUNCMD="" else RUNCMD="" echo "ERROR: Parameter 2 wrong" BREAK_ERROR=1 fi elif [ ${1} == 'thunderbird' ]; then REMOTE_PATH=${PROFILE_TB_SRC} PROFILE_PATH=${PROFILE_TB_DST} if [ "${2}." == 'run.' ]; then RUNCMD="/usr/bin/thunderbird -profile ${PROFILE_TB_DST}/${profilename}" elif [ "${2}." == 'sync.' ]; then RUNCMD="" else RUNCMD="" echo "ERROR: Parameter 2 wrong" BREAK_ERROR=1 fi else echo "Error: First Parameter wrong" BREAK_ERROR=1 fi if [[ ${BREAK_ERROR} == 1 ]]; then echo "Call: ${SCRIPTNAME} [firefox | thunderbird] [run | sync] [ profilename ]" exit 1 fi # optional: -s = silentmodus SYNCCMD="/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=nextcloudcmd com.nextcloud.desktopclient.nextcloud -h -u ${DAVTOKEN_USER} -p ${DAVTOKEN_PASS} --path ${REMOTE_PATH}/${profilename} ${PROFILE_PATH}/${profilename} https://${SERVERFQDN_NC}" SYNCCMD_HIDDENPW=$( echo "${SYNCCMD/${DAVTOKEN_PASS}/***HIDDEN***}" ) echo "Synchronise ${1} with Profile ${profilename}: ${SYNCCMD_HIDDENPW}" mkdir -p ${TEMPDIR} echo "Mozilla Starter" > ${LOGFILE} echo "===============" >> ${LOGFILE} date >> ${LOGFILE} echo "Parameters: $@" >> ${LOGFILE} echo ${SYNCCMD_HIDDENPW} >> ${LOGFILE} echo "" >> ${LOGFILE} mkdir -p ${PROFILE_PATH}/${profilename} ${SYNCCMD} >> ${LOGFILE} 2>&1 if [[ $? -ne 0 ]]; then echo "Error in sync:" echo "****" cat ${LOGFILE} echo "****" echo "" echo "Please check if your Token is setup right and for the Output" echo "Press any key to continue" read -n 1 -s -r echo "" exit 1 fi #Execute if [ "${RUNCMD}." != "." ]; then echo "OK. Starting ${1}..." echo ${RUNCMD} ${RUNCMD} && echo "${1} ended successfully. Please wait for the Profile to sync." if [[ $? -ne 0 ]]; then echo "****" echo "" echo "Error running ${1}, not syncing Profile!" echo "Press any key to continue" read -n 1 -s -r echo "" exit 2 fi sleep 5 ${SYNCCMD} >> ${LOGFILE} 2>&1 if [[ $? -ne 0 ]]; then echo "****" echo "" echo "Error syncing ${SYNCCMD_HIDDENPW} - check Logfile ${LOGFILE}!" read -n 1 -s -r -p "Press any key to continue" echo "" exit 3 fi fi echo "Sucessfully synced. Quit."