forked from obel1x/fedora-OEMDRV
Moved local dir to /opt/sys_config
Improved error logging and added function handling calls with log and return values Improved check for matching sudo rule
This commit is contained in:
@@ -0,0 +1 @@
|
||||
.sync_*.db
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env sh
|
||||
# SPDX-FileCopyrightText: Daniel Pätzold
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
#
|
||||
# Sofwareinstallation script for Nextcloud Desktop
|
||||
#
|
||||
echo "Setup Nextcloud- Sync"
|
||||
|
||||
#Check for root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Error: Script requires root. Please check if ${SCRIPTPATH}/${SCRIPTNAME} is in sudoers rules and if you are a member. And if executed via sudo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Check Token
|
||||
if [ "${DAVTOKEN_USER}." == "." ]; then
|
||||
echo "Error: Script cannot be executed standalone and needs a prereserved Environment. Quit."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Check if Option is Configured to use Nextcloud Desktop Data- Sync
|
||||
if [ "${CLIENT_DATA_DST}." == "." ]; then
|
||||
echo "CLIENT_DATA_DST not set, skipping setup of Nextcloud Desktop sync of Data-Directory"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#Local Vars
|
||||
BASECMD="/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=nextcloud com.nextcloud.desktopclient.nextcloud"
|
||||
SYNCCMD="$BASECMD --userid ${DAVTOKEN_USER} --apppassword ${DAVTOKEN_PASS} --localdirpath ${CLIENT_DATA_DST} --remotedirpath ${CLIENT_DATA_SRC} --serverurl https://${SERVERFQDN_NC}"
|
||||
SYNCCMD_HIDDENPW=$( echo "${SYNCCMD/${DAVTOKEN_PASS}/***HIDDEN***}" )
|
||||
|
||||
#Check if Nextcloud was already setup
|
||||
if grep -q "localPath=${CLIENT_DATA_DST}" "/${SUDO_HOME}/.var/app/com.nextcloud.desktopclient.nextcloud/config/Nextcloud/nextcloud.cfg"; then
|
||||
SETUP_NEEDED="0"
|
||||
else
|
||||
SETUP_NEEDED="1"
|
||||
fi
|
||||
|
||||
#Remove Nextcloud from autostart - if it was started befor the ecrypted mount, i will never sync and always throw an error that the local dir is missing
|
||||
if [ -f "$SUDO_HOME/.config/autostart/com.nextcloud.desktopclient.nextcloud.desktop" ]; then
|
||||
echo "Remove Autostart Nextcloud"
|
||||
rm $SUDO_HOME/.config/autostart/com.nextcloud.desktopclient.nextcloud.desktop
|
||||
#Stopping Nextcloud
|
||||
su -c "$BASECMD --quit 1>/dev/null 2>/dev/null" $SUDO_USER
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
if [ $SETUP_NEEDED = "0" ]; then
|
||||
echo "Nextcloud was already setup, skipping configure and starting Service"
|
||||
echo "If you want to reset, please delete the Folder [HOME]/.var/app/com.nextcloud.desktopclient.nextcloud manually."
|
||||
echo "Command: rm -ri ~/.var/app/com.nextcloud.desktopclient.nextcloud/"
|
||||
su -c "nohup ${BASECMD} 1>/dev/null 2>/dev/null &" $SUDO_USER
|
||||
exit $?
|
||||
fi
|
||||
|
||||
#No check for installed Nextcloud needed, because it will be installed by calling script sync_client_software.sh
|
||||
|
||||
echo "Syncing Files from remote ${CLIENT_DATA_SRC} to local ${CLIENT_DATA_DST}"
|
||||
if [ -d "${CLIENT_DATA_DST}" ]; then
|
||||
echo "Old unsynced Foler ${CLIENT_DATA_DST} was found, renaming to ${CLIENT_DATA_DST}_bak."
|
||||
mv "${CLIENT_DATA_DST}" "${CLIENT_DATA_DST}_bak"
|
||||
fi
|
||||
su -c "mkdir -p ${CLIENT_DATA_DST}" $SUDO_USER
|
||||
#Cleanup Nextcloud Configuration completely, while otherwise, the configure will not work
|
||||
echo "Remove $SUDO_HOME/.var/app/com.nextcloud.desktopclient.nextcloud"
|
||||
rm -rif "$SUDO_HOME/.var/app/com.nextcloud.desktopclient.nextcloud"
|
||||
|
||||
#echo "Exec as $SUDO_USER: ${SYNCCMD}"
|
||||
echo "Exec as $SUDO_USER: ${SYNCCMD_HIDDENPW}"
|
||||
su -c "${SYNCCMD}" $SUDO_USER
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "=========== !!! ========================"
|
||||
echo "Error: It looks like this did not work!"
|
||||
echo "Please check the above output!"
|
||||
exit 1
|
||||
fi
|
||||
# Now start Nextcloud
|
||||
su -c "nohup ${BASECMD} 1>/dev/null 2>/dev/null &" $SUDO_USER
|
||||
echo "Done Setup of Nextcloud."
|
||||
@@ -0,0 +1,17 @@
|
||||
[Desktop Entry]
|
||||
Comment[de_DE]=
|
||||
Comment=
|
||||
Exec=/opt/sys_config/system_setup/mozilla_starter.sh firefox run
|
||||
GenericName[de_DE]=
|
||||
GenericName=
|
||||
Icon=firefox
|
||||
MimeType=
|
||||
Name[de_DE]=Firefox
|
||||
Name=Firefox
|
||||
Path=/opt/sys_config/system_setup
|
||||
StartupNotify=true
|
||||
Terminal=true
|
||||
TerminalOptions=
|
||||
Type=Application
|
||||
X-KDE-SubstituteUID=false
|
||||
X-KDE-Username=
|
||||
@@ -0,0 +1,17 @@
|
||||
[Desktop Entry]
|
||||
Comment[de_DE]=
|
||||
Comment=
|
||||
Exec=/opt/sys_config/system_setup/mozilla_starter.sh thunderbird run
|
||||
GenericName[de_DE]=
|
||||
GenericName=
|
||||
Icon=thunderbird
|
||||
MimeType=
|
||||
Name[de_DE]=Thunderbird
|
||||
Name=Thunderbird
|
||||
Path=/opt/sys_config/system_setup
|
||||
StartupNotify=true
|
||||
Terminal=true
|
||||
TerminalOptions=
|
||||
Type=Application
|
||||
X-KDE-SubstituteUID=false
|
||||
X-KDE-Username=
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env sh
|
||||
# SPDX-FileCopyrightText: Daniel Pätzold
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
#
|
||||
# Sofwareinstallation script for Nextcloud Talk.
|
||||
#
|
||||
|
||||
#Check for root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Error: Script requires root. Please check if ${SCRIPTPATH}/${SCRIPTNAME} is in sudoers rules and if you are a member. And if executed via sudo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp -n *.desktop $SUDO_HOME/Schreibtisch
|
||||
chown $SUDO_USER:$SUDO_USER $SUDO_HOME/Schreibtisch/*.desktop
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud.Talk-linux-x64.flatpak
|
||||
@@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Categories=Network;InstantMessaging;Chat;VideoConference;
|
||||
Comment=Official desktop client for Nextcloud Talk
|
||||
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=electron-wrapper --file-forwarding com.nextcloud.talk @@u %U @@
|
||||
GenericName=Video and Chat Communication
|
||||
Icon=com.nextcloud.talk
|
||||
Name=Nextcloud Talk
|
||||
StartupNotify=true
|
||||
Type=Application
|
||||
X-Flatpak=com.nextcloud.talk
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env sh
|
||||
# SPDX-FileCopyrightText: Daniel Pätzold
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
#
|
||||
# Sofwareinstallation script for Nextcloud Talk.
|
||||
#
|
||||
|
||||
#Check for root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Error: Script requires root. Please check if ${SCRIPTPATH}/${SCRIPTNAME} is in sudoers rules and if you are a member. And if executed via sudo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FILENAME="Nextcloud.Talk-linux-x64.flatpak"
|
||||
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
if [ ${SCRIPTPATH::2} == "//" ]; then
|
||||
SCRIPTPATH=${SCRIPTPATH:1}
|
||||
fi
|
||||
echo "Getting new Version online and saving File to ${SCRIPTPATH}/${FILENAME}"
|
||||
wget -q -P ${SCRIPTPATH} --timestamping https://github.com/nextcloud-releases/talk-desktop/releases/latest/download/${FILENAME}
|
||||
|
||||
# Not needed: Package has no Version, but internal Commit should be automagically detected, see "flatpak list -d"
|
||||
#INSTINFO=$( /usr/bin/flatpak list --columns=app,version | grep com.nextcloud.talk )
|
||||
|
||||
#Hint: If this fails, try to remove and Download the File again
|
||||
|
||||
# Install or update Talk - always in Superuser- Mode
|
||||
# As User you may install Talk in userspace (with -u), but you cannot update the runtime org.freedesktop.Platform/x86_64/XX.YY
|
||||
# So it does not make any sense to install as user
|
||||
/usr/bin/flatpak install -y --or-update --noninteractive --bundle ${SCRIPTPATH}/${FILENAME} && echo Done Install of ${FILENAME}
|
||||
|
||||
#TODO: Check if Talk is installed - if not, exit 1
|
||||
|
||||
exit 0
|
||||
|
||||
#Start App - is not working, always quits with that shell
|
||||
#nohup /usr/bin/flatpak run -u --branch=stable --arch=x86_64 --command=electron-wrapper --file-forwarding com.nextcloud.talk --background >/dev/null &
|
||||
#/usr/bin/flatpak run -u --branch=stable --arch=x86_64 --command=electron-wrapper --file-forwarding com.nextcloud.talk --background @@u %U @@ >/dev/null 2>&1 &
|
||||
@@ -0,0 +1,7 @@
|
||||
Central Software installation script Repository
|
||||
Must be executed from script ../sync_client_software.sh
|
||||
|
||||
The install script here will check for the right environment, and execute the install.sh script in each directory.
|
||||
|
||||
Be sure to name the directories to get sorted the right way.
|
||||
E.g. you may use all base installations with directories beginning with numbers < 0100 and all additional apps with numbers > 0100
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env sh
|
||||
# SPDX-FileCopyrightText: Daniel Pätzold
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
#
|
||||
# Central sofwareinstallation script. Should be called from ""/sys_config/system_setup/sync_client_software.sh install"
|
||||
#
|
||||
if [ "$EUID" -ne 0 ] || [ "$SUDO_USER." == "." ]; then
|
||||
echo "Error: Script requires root privileges and a sudo environment."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Check Token
|
||||
if [ "${DAVTOKEN_USER}." == "." ]; then
|
||||
echo "Error: Script cannot be executed standalone and needs a prereserved environement from logon-script."
|
||||
echo "To get executed without password prompt, use the NOPASSWD rule in sudo. In FreeIPA you can use the sudo-option !authenticate in the sudo rule."
|
||||
echo "Additionally add the sudo command to the rule: ^\/sys_config\/system_setup\/sync_client_software\.sh.*$"
|
||||
echo "Press any key to continue" && read -n 1 -s -r && exit 1
|
||||
fi
|
||||
|
||||
echo "Installing additional Software."
|
||||
for DIR in $(ls -d /${SCRIPTPATH}/*/ | sort); # list directories in the form "/tmp/dirname/"
|
||||
do
|
||||
DIR=${DIR%*/} # remove the trailing "/"
|
||||
if [ -f "${DIR}/install.sh" ]; then
|
||||
echo "*** ==================== ***"
|
||||
echo "*** Installing ${DIR##*/} ***" # print everything after the final "/"
|
||||
cd ${DIR}
|
||||
${DIR}/install.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "*** ==================== ***"
|
||||
echo "Some Error in script, will not continue. Please check."
|
||||
echo "Press any key to continue."
|
||||
read -n 1 -s -r
|
||||
cd ${SCRIPTPATH}
|
||||
exit 1
|
||||
fi
|
||||
echo "*** ==================== ***"
|
||||
fi
|
||||
done
|
||||
cd ${SCRIPTPATH}
|
||||
|
||||
#Last, remove unused Flatpak- Runtimes and unused Data
|
||||
echo "Removing unused Flatpak- Data."
|
||||
flatpak uninstall --unused -y
|
||||
su -c "flatpak uninstall --delete-data -y" $SUDO_USER
|
||||
echo "Sucessfully Installed Software."
|
||||
Reference in New Issue
Block a user