Nextcloud/nextcloud

121 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
clear
nc_path="/var/www/html"
#nc_path="/var/www/nextcloud"
# File owner for Nextcloud data
nc_owner="www-data"
# This script need to know what your nextcloud docker container is called
nc_container="nextcloud"
# Change this if Nextcloud is hosted in a docker container.
# All commands need to change for docker containers
docker=true
if [[ $docker = true ]]
then
command="docker exec --user $nc_owner $nc_container php occ"
else
command="sudo -u $nc_owner php --define apc.enable_cli=1 $nc_path/occ"
fi
echo " This script are to be used as follows..."
echo ""
echo " ./nextcloud [function] [paramiters]"
echo " "
echo " Example: ./nextcloud maintenance on"
echo " Maintenance mode enabled"
echo " "
echo " Available functions are listed below"
echo " "
echo " - maintenance [on/off] "
echo " "
echo " - occ [followed by any official occ commands]"
echo " "
echo " - db [export, import]"
echo " "
echo " - install [smb, zip, nfs, ffmpeg, all "
echo " "
echo " "
echo " "
echo " "
function maintenance () {
clear
# echo $command
case $1 in
on)
m="on"
;;
off)
m="off"
;;
*)
echo ""
echo "Please use either 'on' of 'off' when calling the maintenance function"
echo ""
;;
esac
#sudo -u $nc_owner php --define apc.enable_cli=1 $nc_path/occ maintenance:mode --$m
}
function occ () {
$command $1 $2 $3
#sudo -u $nc_owner php --define apc.enable_cli=1 $nc_path/occ $1 $2 $3
}
function db () {
echo ""
}
function install () {
clear
if [ $1 null ]; then
# Perform an APT update and upgrade first
echo " "
echo " Options for this function are ..."
echo " "
echo " smb - install smb tools to allow network shares for the external drives plugin"
echo " zip - install 7zip to unzip files in nextcloud"
echo " ffmpeg - Install ffmpeg to play video files (this includes SVG support)"
echo " nfs - Install nfs tools to mount nfs shares into docker container"
echo ""
echo ""
else
case $1 in
smb|SMB)
docker exec -i $nc_container sh -c 'apt update'
docker exec -i $nc_container sh -c 'apt upgrade -y'
docker exec -i $nc_container sh -c 'apt install smbclient -y && apt install libsmbclient-dev -y'
docker exec -i $nc_container sh -c 'pecl install smbclient'
docker exec -i $nc_container sh -c 'docker-php-ext-enable smbclient'
;;
zip|ZIP)
docker exec -i $nc_container sh -c 'apt update'
docker exec -i $nc_container sh -c 'apt upgrade -y'
docker exec -i $nc_container sh -c 'pecl -v install rar'
docker exec -i $nc_container sh -c 'apt install p7zip p7zip-full'
;;
ffmpg|FFMPEG)
docker exec -i $nc_container sh -c 'apt update'
docker exec -i $nc_container sh -c 'apt upgrade -y'
docker exec -i $nc_container sh -c 'apt install ffmpeg imagemagick ghostscript -y'
docker exec -i $nc_container sh -c 'apt install libmagickcore-6.q16-6-extra -y' #svg support
;;
nfs|NFS)
;;
*)
echo " You didn't choose anything to install"
echo " options are ... [smb, zip, ffmpeg, nfs]"
echo ""
echo ""
;;
esac
fi
}
"$@"