Repo-based owncloud installation

It looks as if future debian releases won't have
an owncloud package, and so it's now installed in a similar
manner to hubzilla and gnusocial
This commit is contained in:
Bob Mottram 2016-03-11 17:26:17 +00:00
parent c363172933
commit d51a0f4a51
7 changed files with 400 additions and 293 deletions

View File

@ -228,12 +228,14 @@ GVM_REPO="https://github.com/moovweb/gvm"
GVM_COMMIT='25ea8ae158e2861c92e2b22c458e60840157832f'
# Domain name for Owncloud installation
OWNCLOUD_REPO="https://github.com/owncloud/core"
OWNCLOUD_COMMIT='stable9'
OWNCLOUD_DOMAIN_NAME=
OWNCLOUD_CODE=
OWNCLOUD_ONION_PORT=8088
OWNCLOUD_ADMIN_PASSWORD=
OWNCLOUD_MUSIC_APP_REPO="https://github.com/owncloud/music"
OWNCLOUD_MUSIC_APP_COMMIT='7f79afb4ae9a6ecd8f530d87106f960306c0a15a'
OWNCLOUD_MUSIC_APP_COMMIT='0c0e1fadbe31a43f9c98d6a2a7b3960ff881ca0e'
# Domain name for your wiki
WIKI_DOMAIN_NAME=
@ -6227,177 +6229,177 @@ function install_web_server {
echo ' # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;' >> /etc/nginx/nginx.conf
echo '' >> /etc/nginx/nginx.conf
echo ' ##' >> /etc/nginx/nginx.conf
echo ' # Virtual Host Configs' >> /etc/nginx/nginx.conf
echo ' ##' >> /etc/nginx/nginx.conf
echo '' >> /etc/nginx/nginx.conf
echo ' include /etc/nginx/conf.d/*.conf;' >> /etc/nginx/nginx.conf
echo ' include /etc/nginx/sites-enabled/*;' >> /etc/nginx/nginx.conf
echo '}' >> /etc/nginx/nginx.conf
echo ' # Virtual Host Configs' >> /etc/nginx/nginx.conf
echo ' ##' >> /etc/nginx/nginx.conf
echo '' >> /etc/nginx/nginx.conf
echo ' include /etc/nginx/conf.d/*.conf;' >> /etc/nginx/nginx.conf
echo ' include /etc/nginx/sites-enabled/*;' >> /etc/nginx/nginx.conf
echo '}' >> /etc/nginx/nginx.conf
# install a script to easily enable and disable nginx virtual hosts
if [ ! -d $INSTALL_DIR ]; then
mkdir $INSTALL_DIR
fi
cd $INSTALL_DIR
git_clone $NGINX_ENSITE_REPO $INSTALL_DIR/nginx_ensite
cd $INSTALL_DIR/nginx_ensite
git checkout $NGINX_ENSITE_COMMIT -b $NGINX_ENSITE_COMMIT
if ! grep -q "Nginx-ensite commit" $COMPLETION_FILE; then
echo "Nginx-ensite commit:$NGINX_ENSITE_COMMIT" >> $COMPLETION_FILE
else
sed -i "s/Nginx-ensite commit.*/Nginx-ensite commit:$NGINX_ENSITE_COMMIT/g" $COMPLETION_FILE
fi
# install a script to easily enable and disable nginx virtual hosts
if [ ! -d $INSTALL_DIR ]; then
mkdir $INSTALL_DIR
fi
cd $INSTALL_DIR
git_clone $NGINX_ENSITE_REPO $INSTALL_DIR/nginx_ensite
cd $INSTALL_DIR/nginx_ensite
git checkout $NGINX_ENSITE_COMMIT -b $NGINX_ENSITE_COMMIT
if ! grep -q "Nginx-ensite commit" $COMPLETION_FILE; then
echo "Nginx-ensite commit:$NGINX_ENSITE_COMMIT" >> $COMPLETION_FILE
else
sed -i "s/Nginx-ensite commit.*/Nginx-ensite commit:$NGINX_ENSITE_COMMIT/g" $COMPLETION_FILE
fi
make install
nginx_dissite default
echo 'install_web_server' >> $COMPLETION_FILE
}
function install_web_server_access_control {
if [ ! -f /etc/pam.d/nginx ]; then
echo '#%PAM-1.0' > /etc/pam.d/nginx
echo '@include common-auth' >> /etc/pam.d/nginx
echo '@include common-account' >> /etc/pam.d/nginx
echo '@include common-session' >> /etc/pam.d/nginx
fi
}
function configure_php {
sed -i "s/memory_limit = 128M/memory_limit = ${MAX_PHP_MEMORY}M/g" /etc/php5/fpm/php.ini
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php5/fpm/php.ini
sed -i "s/memory_limit = -1/memory_limit = ${MAX_PHP_MEMORY}M/g" /etc/php5/cli/php.ini
sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 50M/g" /etc/php5/fpm/php.ini
sed -i "s/post_max_size = 8M/post_max_size = 50M/g" /etc/php5/fpm/php.ini
}
function install_mariadb {
if grep -Fxq "install_mariadb" $COMPLETION_FILE; then
return
fi
apt-get -y install python-software-properties debconf-utils
apt-get -y install software-properties-common
apt-get -y update
get_mariadb_password
if [ ! $MARIADB_PASSWORD ]; then
if [ -f $IMAGE_PASSWORD_FILE ]; then
MARIADB_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
MARIADB_PASSWORD="$(openssl rand -base64 32)"
fi
echo "$MARIADB_PASSWORD" > $DATABASE_PASSWORD_FILE
chmod 600 $DATABASE_PASSWORD_FILE
echo '' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
echo 'MariaDB / MySql' >> /home/$MY_USERNAME/README
echo '===============' >> /home/$MY_USERNAME/README
echo $"Your MariaDB password is: $MARIADB_PASSWORD" >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
chmod 600 /home/$MY_USERNAME/README
fi
debconf-set-selections <<< "mariadb-server mariadb-server/root_password password $MARIADB_PASSWORD"
debconf-set-selections <<< "mariadb-server mariadb-server/root_password_again password $MARIADB_PASSWORD"
apt-get -y install mariadb-server
apt-get -y remove --purge apache*
if [ -d /etc/apache2 ]; then
rm -rf /etc/apache2
echo $'Removed Apache installation after MariaDB install'
fi
if [ ! -d /etc/mysql ]; then
echo $"ERROR: mariadb-server does not appear to have installed. $CHECK_MESSAGE"
exit 54
fi
mysqladmin -u root password "$MARIADB_PASSWORD"
echo 'install_mariadb' >> $COMPLETION_FILE
}
function backup_databases_script_header {
if [ ! -f /usr/bin/backupdatabases ]; then
# daily
echo '#!/bin/sh' > /usr/bin/backupdatabases
echo '' >> /usr/bin/backupdatabases
echo "EMAIL='$MY_EMAIL_ADDRESS'" >> /usr/bin/backupdatabases
echo '' >> /usr/bin/backupdatabases
echo -n 'MYSQL_PASSWORD=$(cat ' >> /usr/bin/backupdatabases
echo "$DATABASE_PASSWORD_FILE)" >> /usr/bin/backupdatabases
echo 'umask 0077' >> /usr/bin/backupdatabases
echo '' >> /usr/bin/backupdatabases
echo '# exit if we are backing up to friends servers' >> /usr/bin/backupdatabases
echo "if [ -f $FRIENDS_SERVERS_LIST ]; then" >> /usr/bin/backupdatabases
echo ' exit 1' >> /usr/bin/backupdatabases
echo 'fi' >> /usr/bin/backupdatabases
chmod 600 /usr/bin/backupdatabases
chmod +x /usr/bin/backupdatabases
echo '#!/bin/sh' > /etc/cron.daily/backupdatabasesdaily
echo '/usr/bin/backupdatabases' >> /etc/cron.daily/backupdatabasesdaily
chmod 600 /etc/cron.daily/backupdatabasesdaily
chmod +x /etc/cron.daily/backupdatabasesdaily
# weekly
echo '#!/bin/sh' > /etc/cron.weekly/backupdatabasesweekly
echo '' >> /etc/cron.weekly/backupdatabasesweekly
echo 'umask 0077' >> /etc/cron.weekly/backupdatabasesweekly
chmod 600 /etc/cron.weekly/backupdatabasesweekly
chmod +x /etc/cron.weekly/backupdatabasesweekly
# monthly
echo '#!/bin/sh' > /etc/cron.monthly/backupdatabasesmonthly
echo '' >> /etc/cron.monthly/backupdatabasesmonthly
echo 'umask 0077' >> /etc/cron.monthly/backupdatabasesmonthly
chmod 600 /etc/cron.monthly/backupdatabasesmonthly
chmod +x /etc/cron.monthly/backupdatabasesmonthly
fi
}
function repair_databases_script {
if [ -f /etc/cron.hourly/repair ]; then
sed -i "s|/usr/bin/repairdatabase|${PROJECT_NAME}-repair-database|g" /etc/cron.hourly/repair
fi
if grep -Fxq "repair_databases_script" $COMPLETION_FILE; then
return
fi
if [ ! -f $DATABASE_PASSWORD_FILE ]; then
return
fi
echo '#!/bin/bash' > /etc/cron.hourly/repair
echo '' >> /etc/cron.hourly/repair
chmod 600 /etc/cron.hourly/repair
chmod +x /etc/cron.hourly/repair
echo 'repair_databases_script' >> $COMPLETION_FILE
make install
nginx_dissite default
echo 'install_web_server' >> $COMPLETION_FILE
}
function install_owncloud_music_app {
function install_web_server_access_control {
if [ ! -f /etc/pam.d/nginx ]; then
echo '#%PAM-1.0' > /etc/pam.d/nginx
echo '@include common-auth' >> /etc/pam.d/nginx
echo '@include common-account' >> /etc/pam.d/nginx
echo '@include common-session' >> /etc/pam.d/nginx
fi
}
function configure_php {
sed -i "s/memory_limit = 128M/memory_limit = ${MAX_PHP_MEMORY}M/g" /etc/php5/fpm/php.ini
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php5/fpm/php.ini
sed -i "s/memory_limit = -1/memory_limit = ${MAX_PHP_MEMORY}M/g" /etc/php5/cli/php.ini
sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 50M/g" /etc/php5/fpm/php.ini
sed -i "s/post_max_size = 8M/post_max_size = 50M/g" /etc/php5/fpm/php.ini
}
function install_mariadb {
if grep -Fxq "install_mariadb" $COMPLETION_FILE; then
return
fi
apt-get -y install python-software-properties debconf-utils
apt-get -y install software-properties-common
apt-get -y update
get_mariadb_password
if [ ! $MARIADB_PASSWORD ]; then
if [ -f $IMAGE_PASSWORD_FILE ]; then
MARIADB_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
MARIADB_PASSWORD="$(openssl rand -base64 32)"
fi
echo "$MARIADB_PASSWORD" > $DATABASE_PASSWORD_FILE
chmod 600 $DATABASE_PASSWORD_FILE
echo '' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
echo 'MariaDB / MySql' >> /home/$MY_USERNAME/README
echo '===============' >> /home/$MY_USERNAME/README
echo $"Your MariaDB password is: $MARIADB_PASSWORD" >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
chmod 600 /home/$MY_USERNAME/README
fi
debconf-set-selections <<< "mariadb-server mariadb-server/root_password password $MARIADB_PASSWORD"
debconf-set-selections <<< "mariadb-server mariadb-server/root_password_again password $MARIADB_PASSWORD"
apt-get -y install mariadb-server
apt-get -y remove --purge apache*
if [ -d /etc/apache2 ]; then
rm -rf /etc/apache2
echo $'Removed Apache installation after MariaDB install'
fi
if [ ! -d /etc/mysql ]; then
echo $"ERROR: mariadb-server does not appear to have installed. $CHECK_MESSAGE"
exit 54
fi
mysqladmin -u root password "$MARIADB_PASSWORD"
echo 'install_mariadb' >> $COMPLETION_FILE
}
function backup_databases_script_header {
if [ ! -f /usr/bin/backupdatabases ]; then
# daily
echo '#!/bin/sh' > /usr/bin/backupdatabases
echo '' >> /usr/bin/backupdatabases
echo "EMAIL='$MY_EMAIL_ADDRESS'" >> /usr/bin/backupdatabases
echo '' >> /usr/bin/backupdatabases
echo -n 'MYSQL_PASSWORD=$(cat ' >> /usr/bin/backupdatabases
echo "$DATABASE_PASSWORD_FILE)" >> /usr/bin/backupdatabases
echo 'umask 0077' >> /usr/bin/backupdatabases
echo '' >> /usr/bin/backupdatabases
echo '# exit if we are backing up to friends servers' >> /usr/bin/backupdatabases
echo "if [ -f $FRIENDS_SERVERS_LIST ]; then" >> /usr/bin/backupdatabases
echo ' exit 1' >> /usr/bin/backupdatabases
echo 'fi' >> /usr/bin/backupdatabases
chmod 600 /usr/bin/backupdatabases
chmod +x /usr/bin/backupdatabases
echo '#!/bin/sh' > /etc/cron.daily/backupdatabasesdaily
echo '/usr/bin/backupdatabases' >> /etc/cron.daily/backupdatabasesdaily
chmod 600 /etc/cron.daily/backupdatabasesdaily
chmod +x /etc/cron.daily/backupdatabasesdaily
# weekly
echo '#!/bin/sh' > /etc/cron.weekly/backupdatabasesweekly
echo '' >> /etc/cron.weekly/backupdatabasesweekly
echo 'umask 0077' >> /etc/cron.weekly/backupdatabasesweekly
chmod 600 /etc/cron.weekly/backupdatabasesweekly
chmod +x /etc/cron.weekly/backupdatabasesweekly
# monthly
echo '#!/bin/sh' > /etc/cron.monthly/backupdatabasesmonthly
echo '' >> /etc/cron.monthly/backupdatabasesmonthly
echo 'umask 0077' >> /etc/cron.monthly/backupdatabasesmonthly
chmod 600 /etc/cron.monthly/backupdatabasesmonthly
chmod +x /etc/cron.monthly/backupdatabasesmonthly
fi
}
function repair_databases_script {
if [ -f /etc/cron.hourly/repair ]; then
sed -i "s|/usr/bin/repairdatabase|${PROJECT_NAME}-repair-database|g" /etc/cron.hourly/repair
fi
if grep -Fxq "repair_databases_script" $COMPLETION_FILE; then
return
fi
if [ ! -f $DATABASE_PASSWORD_FILE ]; then
return
fi
echo '#!/bin/bash' > /etc/cron.hourly/repair
echo '' >> /etc/cron.hourly/repair
chmod 600 /etc/cron.hourly/repair
chmod +x /etc/cron.hourly/repair
echo 'repair_databases_script' >> $COMPLETION_FILE
}
function install_owncloud_repo_music_app {
if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
return
fi
if ! grep -Fxq "install_owncloud" $COMPLETION_FILE; then
if ! grep -Fxq "install_owncloud_repo" $COMPLETION_FILE; then
echo $'Tried to install the Owncloud music app, but Owncloud installation was not found'
exit 9823
fi
# update to the next commit
set_repo_commit /usr/share/owncloud/apps/music "Owncloud music app commit" "$OWNCLOUD_MUSIC_APP_COMMIT" $OWNCLOUD_MUSIC_APP_REPO
set_repo_commit /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/apps/music "Owncloud music app commit" "$OWNCLOUD_MUSIC_APP_COMMIT" $OWNCLOUD_MUSIC_APP_REPO
if grep -Fxq "install_owncloud_music_app" $COMPLETION_FILE; then
if grep -Fxq "install_owncloud_repo_music_app" $COMPLETION_FILE; then
return
fi
cd /usr/share/owncloud/apps
cd /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/apps
git_clone $OWNCLOUD_MUSIC_APP_REPO Music
cd /usr/share/owncloud/apps/Music
cd /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/apps/Music
git checkout $OWNCLOUD_MUSIC_APP_COMMIT -b $OWNCLOUD_MUSIC_APP_COMMIT
if ! grep -q "Owncloud music app commit" $COMPLETION_FILE; then
echo "Owncloud music app commit:$OWNCLOUD_MUSIC_APP_COMMIT" >> $COMPLETION_FILE
@ -6419,7 +6421,7 @@ function install_owncloud_music_app {
chmod 600 /home/$MY_USERNAME/README
fi
echo 'install_owncloud_music_app' >> $COMPLETION_FILE
echo 'install_owncloud_repo_music_app' >> $COMPLETION_FILE
}
function add_ddns_domain {
@ -6462,49 +6464,76 @@ function configure_owncloud_onion_site {
if [ ! $OWNCLOUD_DOMAIN_NAME ]; then
return
fi
if [ ! -f /etc/owncloud/config.php ]; then
if [ ! -f /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/config.php ]; then
return
fi
if [ ! -f /var/lib/tor/hidden_service_owncloud/hostname ]; then
return
fi
OWNCLOUD_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_owncloud/hostname)
if ! grep -q "${OWNCLOUD_ONION_HOSTNAME}" /etc/owncloud/config.php; then
if ! grep -q "${OWNCLOUD_ONION_HOSTNAME}" /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/config.php; then
sed -i "s|0 => '${OWNCLOUD_DOMAIN_NAME}',|0 => '${OWNCLOUD_DOMAIN_NAME}',
1 => '${OWNCLOUD_ONION_HOSTNAME}',|g" /etc/owncloud/config.php
1 => '${OWNCLOUD_ONION_HOSTNAME}',|g" /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/config.php
sed -i "s|'writable' => false,|'writable' => false,
),
1 =>
array (
'path' => '/usr/share/owncloud/apps',
'path' => '/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/apps',
'url' => '/apps',
'writable' => false,|g" /etc/owncloud/config.php
'writable' => false,|g" /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/config.php
echo $'Owncloud configured for onion site'
fi
}
function install_owncloud {
if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
function upgrade_owncloud {
# upgrades from the debian packaged version to a repo based version
# The debian package for Owncloud is likely to be removed in future debian releases
if [ ! -d /etc/owncloud ]; then
return
fi
OWNCLOUD_COMPLETION_MSG1=$" *** ${PROJECT_NAME} $SYSTEM_TYPE is now installed ***"
OWNCLOUD_COMPLETION_MSG2=$"Open $OWNCLOUD_DOMAIN_NAME in a web browser to complete the setup"
if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" ]]; then
install_owncloud_music_app
backup_to_friends_servers
intrusion_detection
split_gpg_key_into_fragments
# unmount any attached usb drive
if [ -d $USB_MOUNT ]; then
umount $USB_MOUNT
rm -rf $USB_MOUNT
fi
echo ''
echo "$OWNCLOUD_COMPLETION_MSG1"
echo "$OWNCLOUD_COMPLETION_MSG2"
exit 0
# create directories
if [ ! -d /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data ]; then
mkdir /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data
fi
if [ ! -d /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config ]; then
mkdir /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config
fi
# move the data
if [ -d /var/lib/owncloud/data ]; then
# copy users over
cp -rf /var/lib/owncloud/data/* /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data/
# set ownership to www-data
chown -R www-data:www-data /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data
fi
# move the config files
if [ -d /etc/owncloud ]; then
# copy users over
cp -rf /etc/owncloud/* /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/
# set ownership to www-data
chown -R www-data:www-data /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config
fi
# re-index the files
for d in /home/*/ ; do
USRNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USRNAME != "git" && $USRNAME != "mirrors" ]]; then
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ files:scan $USRNAME
fi
done
# TODO enable this once upgrade is confirmed working
#apt-get -y remove --purge owncloud
#rm -rf /etc/owncloud
#rm -rf /usr/share/owncloud
#rm -rf /var/lib/owncloud
}
function install_owncloud_from_repo {
# new version not based on debian package
if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
return
fi
# if this is exclusively a cloud setup
@ -6524,14 +6553,77 @@ function install_owncloud {
exit 6746
fi
fi
OWNCLOUD_PATH=/var/www/$OWNCLOUD_DOMAIN_NAME/htdocs
# was this previously installed from a package?
WAS_INSTALLED_FROM_PACKAGE=
if [ -d /etc/owncloud ]; then
WAS_INSTALLED_FROM_PACKAGE='yes'
fi
# update to a new commit if needed
set_repo_commit $OWNCLOUD_PATH "Owncloud commit" "$OWNCLOUD_COMMIT" $OWNCLOUD_REPO
OWNCLOUD_COMPLETION_MSG1=$" *** ${PROJECT_NAME} $SYSTEM_TYPE is now installed ***"
OWNCLOUD_COMPLETION_MSG2=$"Open $OWNCLOUD_DOMAIN_NAME in a web browser to complete the setup"
if grep -Fxq "install_owncloud_from_repo" $COMPLETION_FILE; then
if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" ]]; then
install_owncloud_repo_music_app
backup_to_friends_servers
intrusion_detection
split_gpg_key_into_fragments
# unmount any attached usb drive
if [ -d $USB_MOUNT ]; then
umount $USB_MOUNT
rm -rf $USB_MOUNT
fi
echo ''
echo "$OWNCLOUD_COMPLETION_MSG1"
echo "$OWNCLOUD_COMPLETION_MSG2"
exit 0
fi
return
fi
apt-get -y install fonts-linuxlibertine fonts-sil-gentium-basic fonts-way-microhei
apt-get -y install libjs-twitter-bootstrap
apt-get -y install owncloud
# ensure that apache hasn't been inadvertantly installed
apt-get -y remove --purge apache*
if [ -d /etc/apache2 ]; then
rm -rf /etc/apache2
echo $'Removed Apache installation after Owncloud install'
fi
# create the directory where owncloud will live
if [ ! -d /var/www/$OWNCLOUD_DOMAIN_NAME ]; then
mkdir /var/www/$OWNCLOUD_DOMAIN_NAME
fi
# clone the owncloud repo
cd /var/www/$OWNCLOUD_DOMAIN_NAME
if [ -d $OWNCLOUD_PATH ]; then
if [ $WAS_INSTALLED_FROM_PACKAGE ]; then
# remove the existing link to /usr/share/owncloud
rm $OWNCLOUD_PATH
if [ -d $OWNCLOUD_PATH ]; then
echo $'Tried to unlink old owncloud, but link remains'
exit 67248
fi
fi
fi
git_clone $OWNCLOUD_REPO $OWNCLOUD_PATH
cd $OWNCLOUD_PATH
git checkout $OWNCLOUD_COMMIT -b $OWNCLOUD_COMMIT
# record the current commit
if ! grep -q "Owncloud commit" $COMPLETION_FILE; then
echo "Owncloud commit:$OWNCLOUD_COMMIT" >> $COMPLETION_FILE
else
sed -i "s/Owncloud commit.*/Owncloud commit:$OWNCLOUD_COMMIT/g" $COMPLETION_FILE
fi
install_mariadb
get_mariadb_password
@ -6566,22 +6658,15 @@ function install_owncloud {
chmod 600 /home/$MY_USERNAME/README
fi
create_database owncloud "$OWNCLOUD_ADMIN_PASSWORD"
if [ ! -d /var/www/$OWNCLOUD_DOMAIN_NAME ]; then
mkdir /var/www/$OWNCLOUD_DOMAIN_NAME
if [ ! $WAS_INSTALLED_FROM_PACKAGE ]; then
create_database owncloud "$OWNCLOUD_ADMIN_PASSWORD"
fi
if [ -d /var/www/$OWNCLOUD_DOMAIN_NAME/htdocs ]; then
rm -rf /var/www/$OWNCLOUD_DOMAIN_NAME/htdocs
fi
ln -s /usr/share/owncloud /var/www/$OWNCLOUD_DOMAIN_NAME/htdocs
if [[ $ONION_ONLY == "no" ]]; then
nginx_http_redirect $OWNCLOUD_DOMAIN_NAME
echo 'server {' >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo ' listen 443 ssl;' >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo " root /var/www/$OWNCLOUD_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo " root $OWNCLOUD_PATH;" >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo " server_name $OWNCLOUD_DOMAIN_NAME;" >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo ' access_log off;' >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo " error_log /var/log/nginx/${OWNCLOUD_DOMAIN_NAME}_error.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
@ -6654,7 +6739,7 @@ function install_owncloud {
fi
echo 'server {' >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo " listen 127.0.0.1:${OWNCLOUD_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo " root /var/www/$OWNCLOUD_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo " root $OWNCLOUD_PATH;" >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo " server_name $OWNCLOUD_DOMAIN_NAME;" >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo ' access_log off;' >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
echo " error_log /var/log/nginx/${OWNCLOUD_DOMAIN_NAME}_error.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
@ -6752,17 +6837,22 @@ function install_owncloud {
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
chmod 600 /home/$MY_USERNAME/README
fi
echo "Owncloud onion domain:${OWNCLOUD_ONION_HOSTNAME}" >> $COMPLETION_FILE
if ! grep -q "Owncloud onion domain" $COMPLETION_FILE; then
echo "Owncloud onion domain:${OWNCLOUD_ONION_HOSTNAME}" >> $COMPLETION_FILE
fi
# update the dynamic DNS
CURRENT_DDNS_DOMAIN=$OWNCLOUD_DOMAIN_NAME
add_ddns_domain
echo "Owncloud domain:$OWNCLOUD_DOMAIN_NAME" >> $COMPLETION_FILE
echo 'install_owncloud' >> $COMPLETION_FILE
if ! grep -q "Owncloud domain" $COMPLETION_FILE; then
echo "Owncloud domain:$OWNCLOUD_DOMAIN_NAME" >> $COMPLETION_FILE
fi
echo 'install_owncloud_from_repo' >> $COMPLETION_FILE
if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" ]]; then
install_owncloud_music_app
install_owncloud_repo_music_app
backup_to_friends_servers
intrusion_detection
split_gpg_key_into_fragments
@ -10737,8 +10827,9 @@ script_for_attaching_usb_drive
install_web_server
install_web_server_access_control
configure_firewall_for_web_server
install_owncloud
install_owncloud_music_app
install_owncloud_from_repo
upgrade_owncloud
install_owncloud_repo_music_app
configure_owncloud_onion_site
upgrade_golang
install_gogs

View File

@ -276,28 +276,29 @@ if grep -q "install_gnu_social" $COMPLETION_FILE; then
fi
fi
#if grep -q "install_owncloud" $COMPLETION_FILE; then
# export OC_PASS="$NEW_USER_PASSWORD"
# occ user:add --password-from-env --display-name="$MY_USERNAME" --group="users" $MY_USERNAME
# if [ ! "$?" = "0" ]; then
# echo 'Owncloud user could not be added'
# if grep -q "install_xmpp" $COMPLETION_FILE; then
# ${PROJECT_NAME}-rmxmpp -e "$MY_USERNAME@$HOSTNAME"
# fi
# if grep -q "Blog domain" $COMPLETION_FILE; then
# if [ -f /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini ]; then
# rm /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
# fi
# fi
# if grep -q "install_sip" $COMPLETION_FILE; then
# ${PROJECT_NAME}-rmsipuser $MY_USERNAME
# fi
# userdel -r $MY_USERNAME
# export OC_PASS=""
# exit 11
# fi
# export OC_PASS=""
#fi
if grep -q "install_owncloud_repo" $COMPLETION_FILE; then
export OC_PASS="$NEW_USER_PASSWORD"
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ user:add --password-from-env --display-name="$MY_USERNAME" --group="users" $MY_USERNAME
if [ ! "$?" = "0" ]; then
echo 'Owncloud user could not be added'
if grep -q "install_xmpp" $COMPLETION_FILE; then
${PROJECT_NAME}-rmxmpp -e "$MY_USERNAME@$HOSTNAME"
fi
if grep -q "Blog domain" $COMPLETION_FILE; then
if [ -f /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini ]; then
rm /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
fi
fi
if grep -q "install_sip" $COMPLETION_FILE; then
${PROJECT_NAME}-rmsipuser $MY_USERNAME
fi
userdel -r $MY_USERNAME
export OC_PASS=""
exit 11
fi
export OC_PASS=""
fi
if grep -q "install_irc_client" $COMPLETION_FILE; then
IRC_PORT=6697

View File

@ -182,7 +182,7 @@ function backup_database {
mkdir -p /root/temp${1}data
fi
echo $"Obtaining ${1} database backup"
mysqldump --password="$DATABASE_PASSWORD" ${1} > /root/temp${1}data/${1}.sql
mysqldump --lock-tables --password="$DATABASE_PASSWORD" ${1} > /root/temp${1}data/${1}.sql
if [ ! -s /root/temp${1}data/${1}.sql ]; then
echo $"${1} database could not be saved"
shred -zu /root/temp${1}data/*
@ -363,9 +363,6 @@ function backup_directories {
"none, none, /etc/nginx/sites-available, web"
"none, none, /home/$ADMIN_USERNAME/.ipfs, ipfs"
"none, none, /var/cache/minidlna, dlna"
"/etc/owncloud, owncloud, /root/tempownclouddata, ownclouddata"
"none, none, /var/lib/owncloud, owncloud"
"none, none, /etc/owncloud, owncloud2"
"/home/git/go/src/github.com/gogits, gogs, /root/tempgogsdata, gogsdata"
"none, none, /home/git/go/src/github.com/gogits/gogs/custom, gogs"
"none, none, /home/git/gogs-repositories, gogsrepos"
@ -373,6 +370,9 @@ function backup_directories {
"none, none, /var/lib/tox-bootstrapd, tox"
"/var/www/${MICROBLOG_DOMAIN_NAME}, gnusocial, /root/tempgnusocialdata, gnusocialdata"
"none, none, /var/www/${MICROBLOG_DOMAIN_NAME}/htdocs, gnusocial"
"/var/www/${OWNCLOUD_DOMAIN_NAME}, owncloud, /root/tempowncloudrepodata, owncloudrepodata"
"none, none, /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data, owncloudrepofiles"
"none, none, /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config, owncloudrepoconfig"
"/var/www/${HUBZILLA_DOMAIN_NAME}, hubzilla, /root/temphubzilladata, hubzilladata"
"none, none, /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs, hubzilla"
"none, none, /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs, blog"
@ -493,7 +493,7 @@ function backup_mariadb {
if [ ! -d /root/tempmariadb ]; then
mkdir /root/tempmariadb
fi
mysqldump --password="$DATABASE_PASSWORD" mysql user > /root/tempmariadb/mysql.sql
mysqldump --lock-tables --password="$DATABASE_PASSWORD" mysql user > /root/tempmariadb/mysql.sql
if [ ! -s /root/tempmariadb/mysql.sql ]; then
echo $"Unable to backup mysql settings"
rm -rf /root/tempmariadb
@ -512,28 +512,28 @@ function valid_backup_destination {
is_valid="yes"
if [[ "$destination_dir" == "hubzilla" || \
"$destination_dir" == "hubzilladata" || \
"$destination_dir" == "gogs" || \
"$destination_dir" == "gogsrepos" || \
"$destination_dir" == "gogsssh" || \
"$destination_dir" == "gnusocial" || \
"$destination_dir" == "gnusocialdata" || \
"$destination_dir" == "mariadb" || \
"$destination_dir" == "config" || \
"$destination_dir" == "letsencrypt" || \
"$destination_dir" == "wiki" || \
"$destination_dir" == "wiki2" || \
"$destination_dir" == "xmpp" || \
"$destination_dir" == "ipfs" || \
"$destination_dir" == "dlna" || \
"$destination_dir" == "tox" || \
"$destination_dir" == "ssl" || \
"$destination_dir" == "ttrss" || \
"$destination_dir" == "blog" || \
"$destination_dir" == "owncloud" || \
"$destination_dir" == "owncloud2" || \
"$destination_dir" == "ownclouddata" || \
"$destination_dir" == "mailinglist" ]]; then
"$destination_dir" == "hubzilladata" || \
"$destination_dir" == "gogs" || \
"$destination_dir" == "gogsrepos" || \
"$destination_dir" == "gogsssh" || \
"$destination_dir" == "gnusocial" || \
"$destination_dir" == "gnusocialdata" || \
"$destination_dir" == "mariadb" || \
"$destination_dir" == "config" || \
"$destination_dir" == "letsencrypt" || \
"$destination_dir" == "wiki" || \
"$destination_dir" == "wiki2" || \
"$destination_dir" == "xmpp" || \
"$destination_dir" == "ipfs" || \
"$destination_dir" == "dlna" || \
"$destination_dir" == "tox" || \
"$destination_dir" == "ssl" || \
"$destination_dir" == "ttrss" || \
"$destination_dir" == "blog" || \
"$destination_dir" == "owncloudrepofiles" || \
"$destination_dir" == "owncloudrepoconfig" || \
"$destination_dir" == "owncloudrepodata" || \
"$destination_dir" == "mailinglist" ]]; then
is_valid="no"
fi

View File

@ -330,11 +330,13 @@ function backup_owncloud {
if [ -d /etc/owncloud ]; then
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
suspend_site ${OWNCLOUD_DOMAIN_NAME}
backup_database_to_friend owncloud
backup_directory_to_friend /root/tempownclouddata ownclouddata
backup_database_to_friend owncloudrepo
backup_directory_to_friend /root/tempowncloudrepodata owncloudrepodata
echo $"Backing up Owncloud data"
backup_directory_to_friend /var/lib/owncloud owncloud
backup_directory_to_friend /etc/owncloud owncloud2
if [ -d /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data ]; then
backup_directory_to_friend /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data owncloudrepofiles
fi
backup_directory_to_friend /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config owncloudrepoconfig
restart_site
fi
}
@ -554,9 +556,8 @@ function valid_backup_destination {
"$destination_dir" == "tox" || \
"$destination_dir" == "ssl" || \
"$destination_dir" == "blog" || \
"$destination_dir" == "owncloud" || \
"$destination_dir" == "owncloud2" || \
"$destination_dir" == "ownclouddata" || \
"$destination_dir" == "owncloudrepo" || \
"$destination_dir" == "owncloudrepodata" || \
"$destination_dir" == "mailinglist" ]]; then
is_valid="no"
fi

View File

@ -826,27 +826,36 @@ function restore_owncloud {
fi
fi
if [ $OWNCLOUD_DOMAIN_NAME ]; then
restore_database owncloud $OWNCLOUD_DOMAIN_NAME
if [ -d $USB_MOUNT/backup/owncloud2 ]; then
restore_directory_from_usb /root/tempowncloud2 owncloud2
cp -r /root/tempowncloud2/etc/owncloud/* /etc/owncloud/
restore_database owncloudrepo $OWNCLOUD_DOMAIN_NAME
if [ -d $USB_MOUNT/backup/owncloudrepofiles ]; then
restore_directory_from_usb /root/tempowncloudrepofiles owncloudrepofiles
cp -r /root/tempowncloudrepofiles/* /
if [ ! "$?" = "0" ]; then
unmount_drive
exit 982
fi
rm -rf /root/tempowncloud
rm -rf /root/tempowncloud2
chown -R www-data:www-data /var/lib/owncloud/data
chown -R www-data:www-data /var/lib/owncloud/backup
chown -R www-data:www-data /var/lib/owncloud/assets
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
occ files:scan $USERNAME
fi
done
ln -s /usr/share/owncloud /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs
rm -rf /root/tempowncloudrepofiles
fi
if [ -d $USB_MOUNT/backup/owncloudrepoconfig ]; then
restore_directory_from_usb /root/tempowncloudrepoconfig owncloudrepoconfig
cp -r /root/tempowncloudrepoconfig/* /
if [ ! "$?" = "0" ]; then
unmount_drive
exit 7825
fi
rm -rf /root/tempowncloudrepoconfig
fi
# re-index the files
chown -R www-data:www-data /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ files:scan $USERNAME
fi
done
fi
}

View File

@ -701,31 +701,35 @@ function restore_owncloud {
fi
if grep -q "Owncloud domain" $COMPLETION_FILE; then
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
restore_database_from_friend owncloud $OWNCLOUD_DOMAIN_NAME
if [ -d $SERVER_DIRECTORY/backup/owncloud ]; then
restore_database_from_friend owncloudrepo $OWNCLOUD_DOMAIN_NAME
if [ -d $SERVER_DIRECTORY/backup/owncloudrepofiles ]; then
echo $"Restoring Owncloud installation"
cp -r /root/tempowncloud/var/lib/owncloud/* /var/lib/owncloud/
cp -r /root/tempowncloudrepofiles/* /
if [ ! "$?" = "0" ]; then
exit 981
exit 1458
fi
restore_directory_from_friend /root/tempowncloud2 owncloud2
cp -r /root/tempowncloud2/etc/owncloud/* /etc/owncloud/
if [ ! "$?" = "0" ]; then
exit 982
fi
rm -rf /root/tempowncloud
rm -rf /root/tempowncloud2
chown -R www-data:www-data /var/lib/owncloud/data
chown -R www-data:www-data /var/lib/owncloud/backup
chown -R www-data:www-data /var/lib/owncloud/assets
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
occ files:scan $USERNAME
fi
done
ln -s /usr/share/owncloud /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs
rm -rf /root/tempowncloudrepofiles
fi
if [ -d $SERVER_DIRECTORY/backup/owncloudrepoconfig ]; then
echo $"Restoring Owncloud installation"
cp -r /root/tempowncloudrepoconfig/* /
if [ ! "$?" = "0" ]; then
exit 2571
fi
rm -rf /root/tempowncloudrepoconfig
fi
chown -R www-data:www-data /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs
# re-index files
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ files:scan $USERNAME
fi
done
fi
}

View File

@ -110,9 +110,10 @@ if [ -f /etc/nginx/.htpasswd ]; then
fi
fi
#if grep -q "install_owncloud" $COMPLETION_FILE; then
# occ user:delete $MY_USERNAME
#fi
if grep -q "install_owncloud_repo" $COMPLETION_FILE; then
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ user:delete $MY_USERNAME
fi
userdel -r $MY_USERNAME