This commit is contained in:
Bob Mottram 2017-08-26 10:25:35 +01:00
commit e9dc1550df
37 changed files with 1213 additions and 350 deletions

View File

@ -22,6 +22,8 @@
Matrix is a federated communications system, typically for multi-user chat, with end-to-end content security features. You can consider it to be like a modernized version of IRC chat where the crypto and access controls have been built in by default. At present Matrix is really only a creature of the clearnet and so there isn't any way to protect the metadata. Despite the talk of security the lack of metadata defenses make this really only suitable for public communications, similar to microblogging or public IRC channels.
Another consideration is that since matrix operates on the usual HTTPS port number (443) this may make it difficult for ISPs or governments to censor this type of communications via port blocking without significant blowback.
* Installation
Log into your system with:

View File

@ -122,7 +122,19 @@ function restore_local_cryptpad {
temp_restore_dir=/root/tempcryptpad
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir cryptpad
cp -r $temp_restore_dir$CRYPTPAD_DIR/datastore/* $CRYPTPAD_DIR/datastore/
if [ ! -d $temp_restore_dir$CRYPTPAD_DIR/datastore ]; then
if [ -d $temp_restore_dir ]; then
cp -r $temp_restore_dir/* $CRYPTPAD_DIR/datastore/
else
systemctl start cryptpad
echo 'Failed to restore cryptpad'
rm -rf $temp_restore_dir
exit 8736529
fi
else
cp -r $temp_restore_dir$CRYPTPAD_DIR/datastore/* $CRYPTPAD_DIR/datastore/
fi
rm -rf $temp_restore_dir
systemctl start cryptpad
fi
}
@ -157,7 +169,20 @@ function restore_remote_cryptpad {
temp_restore_dir=/root/tempcryptpad
function_check restore_directory_from_usb
restore_directory_from_friend $temp_restore_dir cryptpad
cp -r $temp_restore_dir$CRYPTPAD_DIR/datastore/* $CRYPTPAD_DIR/datastore/
if [ ! -d $temp_restore_dir$CRYPTPAD_DIR/datastore ]; then
if [ -d $temp_restore_dir ]; then
cp -r $temp_restore_dir/* $CRYPTPAD_DIR/datastore/
else
systemctl start cryptpad
echo 'Failed to restore cryptpad'
rm -rf $temp_restore_dir
return
fi
else
cp -r $temp_restore_dir$CRYPTPAD_DIR/datastore/* $CRYPTPAD_DIR/datastore/
fi
rm -rf $temp_restore_dir
systemctl start cryptpad
fi
}

View File

@ -113,7 +113,11 @@ function restore_local_dlna {
temp_restore_dir=/root/tempdlna
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir dlna
cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/
if [ -d $temp_restore_dir/var/cache/minidlna ]; then
cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/
else
cp -r $temp_restore_dir/* /var/cache/minidlna/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
@ -139,7 +143,11 @@ function restore_remote_dlna {
temp_restore_dir=/root/tempdlna
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir dlna
cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/
if [ -d $temp_restore_dir/var/cache/minidlna ]; then
cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/
else
cp -r $temp_restore_dir/* /var/cache/minidlna/
fi
if [ ! "$?" = "0" ]; then
exit 982
fi

View File

@ -13,7 +13,7 @@
# License
# =======
#
# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
# Copyright (C) 2014-2017 Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@ -144,59 +144,7 @@ function backup_local_dokuwiki {
fi
}
function restore_local_dokuwiki_legacy {
if [ -d /var/lib/dokuwiki ]; then
echo $"Restoring Legacy Dokuwiki installation"
function_check get_completion_param
DOKUWIKI_DOMAIN_NAME=$(get_completion_param "dokuwiki domain")
temp_restore_dir=/root/tempdokuwiki
function_check restore_directory_from_usb
if [ -d ${USB_MOUNT}/backup/dokuwiki ]; then
restore_directory_from_usb ${temp_restore_dir} dokuwiki
else
restore_directory_from_usb ${temp_restore_dir} wiki
fi
# restore the data
cp -r ${temp_restore_dir}/var/lib/dokuwiki/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
if [ ! "$?" = "0" ]; then
function_check restore_directory_from_usb
set_user_permissions
function_check backup_unmount_drive
backup_unmount_drive
rm -rf ${temp_restore_dir}
exit 73562
fi
# restore the users
cp -r ${temp_restore_dir}/var/lib/dokuwiki/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl
cp -r ${temp_restore_dir}/var/lib/dokuwiki/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf
if [ ! "$?" = "0" ]; then
function_check restore_directory_from_usb
set_user_permissions
function_check backup_unmount_drive
backup_unmount_drive
rm -rf ${temp_restore_dir}
exit 23985
fi
rm -rf ${temp_restore_dir}
chmod -R 755 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
chmod -R 755 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib
chmod 640 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/users.auth.php
chmod 640 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/users.auth.php
chown -R www-data:www-data /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs
echo $"Restore of Legacy Dokuwiki complete"
fi
}
function restore_local_dokuwiki {
if [ -d ${USB_MOUNT}/backup/dokuwiki ]; then
restore_local_dokuwiki_legacy
return
fi
echo $"Restoring Dokuwiki installation"
function_check get_completion_param
DOKUWIKI_DOMAIN_NAME=$(get_completion_param "dokuwiki domain")
@ -205,7 +153,11 @@ function restore_local_dokuwiki {
temp_restore_dir=/root/tempdokuwikidat
function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir} dokuwikidat
cp -r ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
if [ -d ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/data ]; then
cp -r ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
else
cp -r ${temp_restore_dir}/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
fi
if [ ! "$?" = "0" ]; then
function_check restore_directory_from_usb
set_user_permissions
@ -220,8 +172,13 @@ function restore_local_dokuwiki {
temp_restore_dir=/root/tempdokuwikiacl
function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir} dokuwikiacl
cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/
if [ -d ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl ]; then
cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/
else
cp ${temp_restore_dir}/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
cp ${temp_restore_dir}/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/
fi
if [ ! "$?" = "0" ]; then
function_check restore_directory_from_usb
set_user_permissions
@ -257,24 +214,34 @@ function restore_remote_dokuwiki {
if [ -d $SERVER_DIRECTORY/backup/dokuwikidat ]; then
echo $"Restoring Dokuwiki data for $DOKUWIKI_DOMAIN_NAME"
restore_directory_from_friend /root/tempdokuwikidat dokuwikidat
cp -r /root/tempdokuwikidat/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/
temp_restore_dir=/root/tempdokuwikidat
restore_directory_from_friend $temp_restore_dir dokuwikidat
if [ -d $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data ]; then
cp -r $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/
else
cp -r $temp_restore_dir/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/
fi
if [ ! "$?" = "0" ]; then
exit 92634
fi
rm -rf /root/tempdokuwikidat
rm -rf $temp_restore_dir
echo $"Restore of Dokuwiki data complete"
fi
if [ -d $SERVER_DIRECTORY/backup/dokuwikiacl ]; then
echo $"Restoring Dokuwiki users for $DOKUWIKI_DOMAIN_NAME"
restore_directory_from_friend /root/tempdokuwikiacl dokuwikiacl
cp -r /root/tempdokuwikidat/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
temp_restore_dir=/root/tempdokuwikiacl
restore_directory_from_friend $temp_restore_dir dokuwikiacl
if [ -d $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl ]; then
cp -r $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
else
cp -r $temp_restore_dir/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
fi
if [ ! "$?" = "0" ]; then
exit 735287
fi
rm -rf /root/tempdokuwikiacl
rm -rf $temp_restore_dir
echo $"Restore of Dokuwiki users complete"
fi

View File

@ -81,7 +81,14 @@ function restore_local_emacs {
echo $"Restoring Emacs config for $USERNAME"
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir emacs/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
else
if [ ! -d /home/$USERNAME/.emacs.d ]; then
mkdir /home/$USERNAME/.emacs.d
fi
cp -r $temp_restore_dir/* /home/$USERNAME/.emacs.d
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
@ -90,7 +97,11 @@ function restore_local_emacs {
backup_unmount_drive
exit 664
fi
cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
else
cp -f $temp_restore_dir/dotemacs /home/$USERNAME/.emacs
fi
rm -rf $temp_restore_dir
fi
done
@ -125,7 +136,14 @@ function restore_remote_emacs {
echo $"Restoring Emacs config for $USERNAME"
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir emacs/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
else
if [ ! -d /home/$USERNAME/.emacs.d ]; then
mkdir /home/$USERNAME/.emacs.d
fi
cp -r $temp_restore_dir/* /home/$USERNAME/.emacs.d/*
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
@ -134,7 +152,11 @@ function restore_remote_emacs {
backup_unmount_drive
exit 664
fi
cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
else
cp -f $temp_restore_dir/dotemacs /home/$USERNAME/.emacs
fi
rm -rf $temp_restore_dir
fi
done

View File

@ -251,7 +251,11 @@ function restore_local_ghost {
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir ghostcontent
if [ -d $temp_restore_dir ]; then
cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
if [ -d $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content ]; then
cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
else
cp -r $temp_restore_dir/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
fi
chown -R ghost:ghost /var/www/$GHOST_DOMAIN_NAME/htdocs/content
rm -rf $temp_restore_dir
fi
@ -291,7 +295,11 @@ function restore_remote_ghost {
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir ghostcontent
if [ -d $temp_restore_dir ]; then
cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
if [ -d $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content ]; then
cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
else
cp -r $temp_restore_dir/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
fi
chown -R ghost: /var/www/$GHOST_DOMAIN_NAME/htdocs
rm -rf $temp_restore_dir
fi

View File

@ -430,16 +430,31 @@ function restore_local_gnusocial {
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir gnusocialconfig
if [ -d $temp_restore_dir ]; then
cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
if [ -d cp $temp_restore_dir$gnusocial_dir ]; then
cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
else
cp $temp_restore_dir/backup/config.php $gnusocial_dir/
if [ ! -d $gnusocial_dir/static ]; then
mkdir $gnusocial_dir/static
fi
cp -rp $temp_restore_dir/static/* $gnusocial_dir/static/
fi
chown www-data:www-data $gnusocial_dir/config.php
cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
chown -R www-data:www-data $gnusocial_dir/static
rm -rf $temp_restore_dir
fi
restore_directory_from_usb $temp_restore_dir gnusocialfile
if [ -d $temp_restore_dir ]; then
cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
if [ -d cp $temp_restore_dir$gnusocial_dir/file ]; then
cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
else
if [ ! -d $gnusocial_dir/file ]; then
mkdir $gnusocial_dir/file
fi
cp -rp $temp_restore_dir/* $gnusocial_dir/file
fi
chown -R www-data:www-data $gnusocial_dir/file
rm -rf $temp_restore_dir
fi
@ -511,16 +526,31 @@ function restore_remote_gnusocial {
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir gnusocialconfig
if [ -d $temp_restore_dir ]; then
cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
if [ -d $temp_restore_dir$gnusocial_dir ]; then
cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
else
cp $temp_restore_dir/backup/config.php $gnusocial_dir/
if [ ! -d $gnusocial_dir/static ]; then
mkdir $gnusocial_dir/static
fi
cp -rp $temp_restore_dir/static/* $gnusocial_dir/static/
fi
chown www-data:www-data $gnusocial_dir/config.php
cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
chown -R www-data:www-data $gnusocial_dir/static
rm -rf $temp_restore_dir
fi
restore_directory_from_friend $temp_restore_dir gnusocialfile
if [ -d $temp_restore_dir ]; then
cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
if [ ! -d $temp_restore_dir$gnusocial_dir/file ]; then
cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
else
if [ ! -d $gnusocial_dir/file ]; then
mkdir $gnusocial_dir/file
fi
cp -rp $temp_restore_dir/* $gnusocial_dir/file/
fi
chown -R www-data:www-data $gnusocial_dir/file
rm -rf $temp_restore_dir
fi

View File

@ -249,7 +249,11 @@ function restore_local_gogs {
if [ ! -d /home/${GOGS_USERNAME}/custom ]; then
mkdir -p /home/${GOGS_USERNAME}/custom
fi
cp -r ${temp_restore_dir}/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom
if [ ! -d ${temp_restore_dir}/home/${GOGS_USERNAME}/custom ]; then
cp -r ${temp_restore_dir}/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom
else
cp -r ${temp_restore_dir}/* /home/${GOGS_USERNAME}/custom/
fi
if [ ! "$?" = "0" ]; then
function_check set_user_permissions
set_user_permissions
@ -260,7 +264,11 @@ function restore_local_gogs {
echo $"Restoring Gogs repos"
function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir}repos gogsrepos
cp -r ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
if [ ! -d ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories ]; then
cp -r ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
else
cp -r ${temp_restore_dir}/* /home/${GOGS_USERNAME}/gogs-repositories/
fi
if [ ! "$?" = "0" ]; then
function_check set_user_permissions
set_user_permissions
@ -274,7 +282,11 @@ function restore_local_gogs {
if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then
mkdir /home/${GOGS_USERNAME}/.ssh
fi
cp -r ${temp_restore_dir}ssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
if [ -d ${temp_restore_dir}ssh/home/${GOGS_USERNAME}/.ssh ]; then
cp -r ${temp_restore_dir}ssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
else
cp -r ${temp_restore_dir}/* /home/${GOGS_USERNAME}/.ssh/
fi
if [ ! "$?" = "0" ]; then
function_check set_user_permissions
set_user_permissions
@ -338,13 +350,21 @@ function restore_remote_gogs {
if [ ! -d /home/${GOGS_USERNAME}/custom ]; then
mkdir -p /home/${GOGS_USERNAME}/custom
fi
cp -r /root/tempgogs/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom/
if [ -d /root/tempgogs/home/${GOGS_USERNAME}/custom ]; then
cp -r /root/tempgogs/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom/
else
cp -r /root/tempgogs/* /home/${GOGS_USERNAME}/custom/
fi
if [ ! "$?" = "0" ]; then
exit 58852
fi
echo $"Restoring Gogs repos"
restore_directory_from_friend /root/tempgogsrepos gogsrepos
cp -r /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
if [ -d /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories ]; then
cp -r /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
else
cp -r /root/tempgogsrepos/* /home/${GOGS_USERNAME}/gogs-repositories/
fi
if [ ! "$?" = "0" ]; then
exit 7649
fi
@ -353,7 +373,11 @@ function restore_remote_gogs {
if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then
mkdir /home/${GOGS_USERNAME}/.ssh
fi
cp -r /root/tempgogsssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
if [ -d /root/tempgogsssh/home/${GOGS_USERNAME}/.ssh ]; then
cp -r /root/tempgogsssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
else
cp -r /root/tempgogsssh/* /home/${GOGS_USERNAME}/.ssh/
fi
if [ ! "$?" = "0" ]; then
exit 74239
fi

View File

@ -249,8 +249,15 @@ function restore_local_htmly {
fi
mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous
fi
temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
if [ -d ${temp_restore_dir}/var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
else
if [ ! -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
mkdir /var/www/${HTMLY_DOMAIN_NAME}/htdocs
fi
cp -r ${temp_restore_dir}/* /var/www/${HTMLY_DOMAIN_NAME}/htdocs/
fi
if [ ! "$?" = "0" ]; then
if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs
@ -315,8 +322,17 @@ function restore_remote_htmly {
fi
mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous
fi
temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
if [ -d ${temp_restore_dir}/var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
else
if [ ! -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
mkdir /var/www/${HTMLY_DOMAIN_NAME}/htdocs
fi
cp -r ${temp_restore_dir}/* /var/www/${HTMLY_DOMAIN_NAME}/htdocs/
fi
if [ ! "$?" = "0" ]; then
if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs

View File

@ -119,7 +119,11 @@ function restore_local_ipfs {
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir ipfs
ADMIN_USERNAME=$(get_completion_param "Admin user")
cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs ]; then
cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
else
cp -rf $temp_restore_dir/* /home/$ADMIN_USERNAME/.ipfs
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
@ -151,7 +155,11 @@ function restore_remote_ipfs {
temp_restore_dir=/root/tempipfs
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir ipfs
cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs ]; then
cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
else
cp -rf $temp_restore_dir/* /home/$ADMIN_USERNAME/.ipfs
fi
if [ ! "$?" = "0" ]; then
function_check set_user_permissions
set_user_permissions

View File

@ -243,14 +243,25 @@ function restore_local_kanboard {
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir kanboardconfig
if [ -d $temp_restore_dir ]; then
cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/
if [ -d $temp_restore_dir$kanboard_dir/backup ]; then
cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/
else
cp $temp_restore_dir/config.php $kanboard_dir/
fi
chown www-data:www-data $kanboard_dir/config.php
rm -rf $temp_restore_dir
fi
restore_directory_from_usb $temp_restore_dir kanboardfile
if [ -d $temp_restore_dir ]; then
cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/
if [ -d $temp_restore_dir$kanboard_dir/data ]; then
cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/
else
if [ ! -d $kanboard_dir/data ]; then
mkdir $kanboard_dir/data
fi
cp -rp $temp_restore_dir/* $kanboard_dir/data/
fi
chown -R www-data:www-data $kanboard_dir/data
rm -rf $temp_restore_dir
fi
@ -313,14 +324,25 @@ function restore_remote_kanboard {
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir kanboardconfig
if [ -d $temp_restore_dir ]; then
cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/
if [ -d $temp_restore_dir$kanboard_dir/backup ]; then
cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/
else
cp $temp_restore_dir/config.php $kanboard_dir/
fi
chown www-data:www-data $kanboard_dir/config.php
rm -rf $temp_restore_dir
fi
restore_directory_from_friend $temp_restore_dir kanboardfile
if [ -d $temp_restore_dir ]; then
cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/
if [ -d $temp_restore_dir$kanboard_dir/data ]; then
cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/
else
if [ ! -d $kanboard_dir/data ]; then
mkdir $kanboard_dir/data
fi
cp -rp $temp_restore_dir/* $kanboard_dir/data/
fi
chown -R www-data:www-data $kanboard_dir/data
rm -rf $temp_restore_dir
fi

View File

@ -202,7 +202,11 @@ function restore_local_keyserver {
temp_restore_dir=/root/tempkeyserverconfig
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir keyserverconfig
cp -r $temp_restore_dir/etc/sks/* /etc/sks/
if [ -d $temp_restore_dir/etc/sks ]; then
cp -r $temp_restore_dir/etc/sks/* /etc/sks/
else
cp -r $temp_restore_dir/* /etc/sks/
fi
rm -rf $temp_restore_dir
chown -Rc debian-sks: /etc/sks/sksconf
chown -Rc debian-sks: /etc/sks/mailsync
@ -211,7 +215,14 @@ function restore_local_keyserver {
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir keyserver
mv /var/lib/sks/DB /var/lib/sks/DB_prev
cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB
if [ -d $temp_restore_dir/var/lib/sks/DB ]; then
cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB
else
if [ ! -d /var/lib/sks/DB ]; then
mkdir /var/lib/sks/DB
fi
cp -r $temp_restore_dir/* /var/lib/sks/DB
fi
if [ ! "$?" = "0" ]; then
# restore the old database
rm -rf /var/lib/sks/DB
@ -272,7 +283,11 @@ function restore_remote_keyserver {
temp_restore_dir=/root/tempkeyserverconfig
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir keyserverconfig
cp -r $temp_restore_dir/etc/sks/* /etc/sks/
if [ -d $temp_restore_dir/etc/sks ]; then
cp -r $temp_restore_dir/etc/sks/* /etc/sks/
else
cp -r $temp_restore_dir/* /etc/sks/
fi
rm -rf $temp_restore_dir
chown -Rc debian-sks: /etc/sks/sksconf
chown -Rc debian-sks: /etc/sks/mailsync
@ -281,7 +296,14 @@ function restore_remote_keyserver {
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir keyserver
mv /var/lib/sks/DB /var/lib/sks/DB_prev
cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB
if [ -d $temp_restore_dir/var/lib/sks/DB ]; then
cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB
else
if [ ! -d /var/lib/sks/DB ]; then
mkdir /var/lib/sks/DB
fi
cp -r $temp_restore_dir/* /var/lib/sks/DB
fi
if [ ! "$?" = "0" ]; then
# restore the old database
rm -rf /var/lib/sks/DB

View File

@ -54,14 +54,42 @@ MATRIX_REPO="https://github.com/matrix-org/synapse"
MATRIX_COMMIT='c45dc6c62aa2a2e83a10d8116a709dfd8c144e3c'
REPORT_STATS="no"
MATRIX_SECRET=
MATRIX_EXPIRE_MONTHS=1
matrix_variables=(ONION_ONLY
MY_USERNAME
MATRIX_SECRET
DEFAULT_DOMAIN_NAME
MATRIX_DOMAIN_NAME
MATRIX_EXPIRE_MONTHS
MATRIX_CODE)
function matrix_expire_old_posts {
read_config_param MY_USERNAME
read_config_param MATRIX_DOMAIN_NAME
read_config_param MATRIX_EXPIRE_MONTHS
read_config_param MATRIX_PORT
matrix_remove_posts=/usr/bin/matrix-remove
echo '#!/bin/bash' > $matrix_remove_posts
echo "cd $MATRIX_DATA_DIR" >> $matrix_remove_posts
echo 'ROOM=$1' >> $matrix_remove_posts
echo "ADMIN=\"@${MY_USERNAME}:$MATRIX_DOMAIN_NAME\"" >> $matrix_remove_posts
echo "TIME='$MATRIX_EXPIRE_MONTHS months ago'" >> $matrix_remove_posts
echo "UNIX_TIMESTAMP=\$(date +%s%3N --date='TZ=\"UTC+0\" '\"\$TIME\")" >> $matrix_remove_posts
echo 'BUSY="pragma busy_timeout=20000"' >> $matrix_remove_posts
echo "BUFFER=\$(sqlite3 homeserver.db \"\$BUSY;select event_id from events where type='m.room.message' and received_ts<'\$UNIX_TIMESTAMP' and room_id='\$ROOM' order by received_ts desc limit 1;\")" >> $matrix_remove_posts
echo "EVENT_ID=\$(echo \$BUFFER|awk '{print \$2}')" >> $matrix_remove_posts
echo "BUFFER=\$(sqlite3 homeserver.db \"\$BUSY;select token from access_tokens where user_id like '\$ADMIN' order by id desc limit 1;\")" >> $matrix_remove_posts
echo "TOKEN=\$(echo \$BUFFER|awk '{print \$2}')" >> $matrix_remove_posts
echo 'set -x' >> $matrix_remove_posts
echo "curl -v -X POST 'https://$MATRIX_DOMAIN_NAME/_matrix/client/r0/admin/purge_history/'\$ROOM'/'\$EVENT_ID'?access_token='\$TOKEN" >> $matrix_remove_posts
chmod +x $matrix_remove_posts
}
function logging_on_matrix {
if [ -f /var/lib/matrix/homeserver.yaml ]; then
if ! grep -q "log_file: /etc/matrix/homeserver.log" /var/lib/matrix/homeserver.yaml; then
@ -415,7 +443,11 @@ function restore_local_matrix {
temp_restore_dir=/root/tempmatrix
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir matrix
cp -r $temp_restore_dir/etc/matrix/* /etc/matrix
if [ -d $temp_restore_dir/etc/matrix ]; then
cp -r $temp_restore_dir/etc/matrix/* /etc/matrix
else
cp -r $temp_restore_dir/* /etc/matrix/
fi
if [ ! "$?" = "0" ]; then
function_check backup_unmount_drive
backup_unmount_drive
@ -426,7 +458,11 @@ function restore_local_matrix {
temp_restore_dir=/root/tempmatrixdata
restore_directory_from_usb $temp_restore_dir matrixdata
cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR
if [ -d $temp_restore_dir$MATRIX_DATA_DIR ]; then
cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR
else
cp -r $temp_restore_dir/* $MATRIX_DATA_DIR/
fi
if [ ! "$?" = "0" ]; then
function_check backup_unmount_drive
backup_unmount_drive
@ -472,7 +508,11 @@ function restore_remote_matrix {
temp_restore_dir=/root/tempmatrix
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir matrix
cp -r $temp_restore_dir/etc/matrix/* /etc/matrix
if [ -d $temp_restore_dir/etc/matrix ]; then
cp -r $temp_restore_dir/etc/matrix/* /etc/matrix
else
cp -r $temp_restore_dir/* /etc/matrix/
fi
if [ ! "$?" = "0" ]; then
exit 38935
fi
@ -481,7 +521,11 @@ function restore_remote_matrix {
temp_restore_dir=/root/tempmatrixdata
restore_directory_from_friend $temp_restore_dir matrixdata
cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR
if [ -d $temp_restore_dir$MATRIX_DATA_DIR ]; then
cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR
else
cp -r $temp_restore_dir/* $MATRIX_DATA_DIR/
fi
if [ ! "$?" = "0" ]; then
exit 60923
fi
@ -635,6 +679,9 @@ function install_home_server {
fi
chmod -R 700 $MATRIX_DATA_DIR/homeserver.db
cd $MATRIX_DATA_DIR
sqlite3 homeserver.db "PRAGMA auto_vacuum = FULL;"
MATRIX_ONION_HOSTNAME=$(add_onion_service matrix ${MATRIX_PORT} ${MATRIX_ONION_PORT})
echo "HiddenServicePort ${MATRIX_HTTP_PORT} 127.0.0.1:${MATRIX_FEDERATION_ONION_PORT}" >> /etc/tor/torrc
systemctl restart tor

View File

@ -177,7 +177,11 @@ function restore_local_mediagoblin {
temp_restore_dir=/root/tempmediagoblin
function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir} mediagoblin
cp -r ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR/* $MEDIAGOBLIN_BASE_DIR/
if [ -d ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR ]; then
cp -r ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR/* $MEDIAGOBLIN_BASE_DIR/
else
cp -r ${temp_restore_dir}/* $MEDIAGOBLIN_BASE_DIR/
fi
if [ ! "$?" = "0" ]; then
function_check restore_directory_from_usb
set_user_permissions
@ -186,7 +190,11 @@ function restore_local_mediagoblin {
exit 45327
fi
restore_directory_from_usb ${temp_restore_dir}2 mediagoblindata
cp -r ${temp_restore_dir}2/var/lib/mediagoblin/* /var/lib/mediagoblin/
if [ -d ${temp_restore_dir}2/var/lib/mediagoblin ]; then
cp -r ${temp_restore_dir}2/var/lib/mediagoblin/* /var/lib/mediagoblin/
else
cp -r ${temp_restore_dir}2/* /var/lib/mediagoblin/
fi
if [ ! "$?" = "0" ]; then
function_check set_user_permissions
set_user_permissions
@ -214,21 +222,30 @@ function backup_remote_mediagoblin {
function restore_remote_mediagoblin {
MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
if [ -d $SERVER_DIRECTORY/backup/mediagoblin ]; then
temp_restore_dir=/root/tempmediagoblin
function_check get_completion_param
MEDIAGOBLIN_DOMAIN_NAME=$(get_completion_param "mediagoblin domain")
function_check restore_directory_from_friend
restore_directory_from_friend /root/tempmediagoblin mediagoblin
cp -r /root/tempmediagoblin/var/lib/mediagoblin/* /var/lib/mediagoblin/
restore_directory_from_friend $temp_restore_dir mediagoblin
if [ -d ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR ]; then
cp -r ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR/* $MEDIAGOBLIN_BASE_DIR/
else
cp -r ${temp_restore_dir}/* $MEDIAGOBLIN_BASE_DIR/
fi
if [ ! "$?" = "0" ]; then
exit 264824
fi
restore_directory_from_friend /root/tempmediagoblin2 mediagoblindata
cp -r /root/tempmediagoblin/var/lib/mediagoblin/* /var/lib/mediagoblin/
restore_directory_from_friend ${temp_restore_dir}2 mediagoblindata
if [ -d ${temp_restore_dir}2/var/lib/mediagoblin ]; then
cp -r ${temp_restore_dir}2/var/lib/mediagoblin/* /var/lib/mediagoblin/
else
cp -r ${temp_restore_dir}2/* /var/lib/mediagoblin/
fi
if [ ! "$?" = "0" ]; then
exit 268492
fi
rm -rf /root/tempmediagoblin
rm -rf /root/tempmediagoblin2
rm -rf ${temp_restore_dir}
rm -rf ${temp_restore_dir}2
chown -hR mediagoblin:www-data $MEDIAGOBLIN_BASE_DIR
chown -hR mediagoblin:www-data /var/lib/mediagoblin
chmod -R g+wx /var/lib/mediagoblin

View File

@ -107,7 +107,11 @@ function restore_local_mumble {
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir voip
restore_directory_from_usb $temp_restore_dir mumble
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
else
cp -f $temp_restore_dir/mumble-server.ini /etc/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
@ -116,7 +120,11 @@ function restore_local_mumble {
backup_unmount_drive
exit 3679
fi
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
else
cp -f $temp_restore_dir/mumble-server.sqlite /var/lib/mumble-server/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
@ -152,17 +160,29 @@ function restore_remote_mumble {
temp_restore_dir=/root/tempmumble
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir mumble
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
else
cp -f $temp_restore_dir/mumble-server.ini /etc/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
exit 7823
fi
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
else
cp -f $temp_restore_dir/sipwitch.conf /etc/sipwitch.conf
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
exit 7823
fi
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
if [ $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
else
cp -f $temp_restore_dir/mumble-server.sqlite /var/lib/mumble-server/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
exit 276

View File

@ -254,8 +254,13 @@ function restore_local_nextcloud {
temp_restore_dir=/root/tempnextcloudfiles
restore_directory_from_usb $temp_restore_dir nextcloudfiles
temp_source_dir=$(find ${temp_restore_dir} -name data)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/
if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data ]; then
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data /var/www/${NEXTCLOUD_DOMAIN_NAME}/
else
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/
fi
if [ ! "$?" = "0" ]; then
set_user_permissions
backup_unmount_drive
@ -265,8 +270,13 @@ function restore_local_nextcloud {
temp_restore_dir=/root/tempnextcloudconfig
restore_directory_from_usb $temp_restore_dir nextcloudconfig
temp_source_dir=$(find ${temp_restore_dir} -name config)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/
if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config ]; then
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
else
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/
fi
if [ ! "$?" = "0" ]; then
set_user_permissions
backup_unmount_drive
@ -324,8 +334,13 @@ function restore_remote_nextcloud {
temp_restore_dir=/root/tempnextcloudfiles
restore_directory_from_friend $temp_restore_dir nextcloudfiles
temp_source_dir=$(find ${temp_restore_dir} -name data)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/
if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data ]; then
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data /var/www/${NEXTCLOUD_DOMAIN_NAME}/
else
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/
fi
if [ ! "$?" = "0" ]; then
exit 768254
fi
@ -333,8 +348,13 @@ function restore_remote_nextcloud {
temp_restore_dir=/root/tempnextcloudconfig
restore_directory_from_friend $temp_restore_dir nextcloudconfig
temp_source_dir=$(find ${temp_restore_dir} -name config)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/
if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config ]; then
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
else
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/
fi
if [ ! "$?" = "0" ]; then
exit 573427
fi

View File

@ -449,7 +449,11 @@ function restore_local_pelican {
temp_restore_dir=/root/temppelican
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir pelican
cp -r $temp_restore_dir/etc/blog/* /etc/blog/
if [ -d $temp_restore_dir/etc/blog ]; then
cp -r $temp_restore_dir/etc/blog/* /etc/blog/
else
cp -r $temp_restore_dir/* /etc/blog/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
@ -466,7 +470,11 @@ function restore_local_pelican {
temp_restore_dir=/root/temppelican-site
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir pelican-site
cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
if [ -d $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
else
cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
@ -495,7 +503,11 @@ function restore_remote_pelican {
temp_restore_dir=/root/temppelican
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir pelican
cp -r $temp_restore_dir/etc/blog/* /etc/blog/
if [ -d $temp_restore_dir/etc/blog ]; then
cp -r $temp_restore_dir/etc/blog/* /etc/blog/
else
cp -r $temp_restore_dir/* /etc/blog/
fi
if [ ! "$?" = "0" ]; then
exit 782352
fi
@ -507,7 +519,11 @@ function restore_remote_pelican {
temp_restore_dir=/root/temppelican-site
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir pelican-site
cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
if [ -d $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
else
cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
fi
if [ ! "$?" = "0" ]; then
exit 76382562
fi

View File

@ -446,16 +446,31 @@ function restore_local_postactiv {
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir postactivconfig
if [ -d $temp_restore_dir ]; then
cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
if [ -d $temp_restore_dir$postactiv_dir ]; then
cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
else
cp $temp_restore_dir/backup/config.php $postactiv_dir/
if [ ! -d $postactiv_dir/static ]; then
mkdir $postactiv_dir/static
fi
cp -rp $temp_restore_dir/static/* $postactiv_dir/static/
fi
chown www-data:www-data $postactiv_dir/config.php
cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
chown -R www-data:www-data $postactiv_dir/static
rm -rf $temp_restore_dir
fi
restore_directory_from_usb $temp_restore_dir postactivfile
if [ -d $temp_restore_dir ]; then
cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
if [ -d $temp_restore_dir$postactiv_dir/file ]; then
cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
else
if [ ! -d $postactiv_dir/file ]; then
mkdir $postactiv_dir/file
fi
cp -rp $temp_restore_dir/* $postactiv_dir/file/
fi
chown -R www-data:www-data $postactiv_dir/file
rm -rf $temp_restore_dir
fi
@ -527,16 +542,31 @@ function restore_remote_postactiv {
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir postactivconfig
if [ -d $temp_restore_dir ]; then
cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
if [ -d $temp_restore_dir$postactiv_dir ]; then
cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
else
cp $temp_restore_dir/config.php $postactiv_dir/
if [ ! -d $postactiv_dir/static ]; then
mkdir $postactiv_dir/static
fi
cp -rp $temp_restore_dir/static/* $postactiv_dir/static/
fi
chown www-data:www-data $postactiv_dir/config.php
cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
chown -R www-data:www-data $postactiv_dir/static
rm -rf $temp_restore_dir
fi
restore_directory_from_friend $temp_restore_dir postactivfile
if [ -d $temp_restore_dir ]; then
cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
if [ -d $temp_restore_dir$postactiv_dir/file ]; then
cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
else
if [ ! -d $postactiv_dir/file ]; then
mkdir $postactiv_dir/file
fi
cp -rp $temp_restore_dir/* $postactiv_dir/file/
fi
chown -R www-data:www-data $postactiv_dir/file
rm -rf $temp_restore_dir
fi

View File

@ -214,7 +214,11 @@ function restore_local_radicale {
temp_restore_dir=/root/tempradicale
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir radicale
cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY}
if [ -d $temp_restore_dir${RADICALE_DIRECTORY} ]; then
cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY}
else
cp -r $temp_restore_dir/* ${RADICALE_DIRECTORY}/
fi
if [ ! "$?" = "0" ]; then
function_check backup_unmount_drive
backup_unmount_drive
@ -224,7 +228,11 @@ function restore_local_radicale {
temp_restore_dir=/root/tempradicalewww
restore_directory_from_usb $temp_restore_dir radicalewww
cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale
if [ -d $temp_restore_dir/var/www/radicale ]; then
cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale
else
cp -r $temp_restore_dir/* /var/www/radicale/*
fi
if [ ! "$?" = "0" ]; then
function_check backup_unmount_drive
backup_unmount_drive
@ -251,7 +259,11 @@ function restore_remote_radicale {
temp_restore_dir=/root/tempradicale
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir radicale
cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY}
if [ -d $temp_restore_dir${RADICALE_DIRECTORY} ]; then
cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY}
else
cp -r $temp_restore_dir/* ${RADICALE_DIRECTORY}/
fi
if [ ! "$?" = "0" ]; then
exit 236746
fi
@ -259,7 +271,11 @@ function restore_remote_radicale {
temp_restore_dir=/root/tempradicalewww
restore_directory_from_friend $temp_restore_dir radicalewww
cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale
if [ -d $temp_restore_dir/var/www/radicale ]; then
cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale
else
cp -r $temp_restore_dir/* /var/www/radicale
fi
if [ ! "$?" = "0" ]; then
exit 3674284
fi

View File

@ -33,9 +33,9 @@ VARIANTS='full full-vim chat'
IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1
RIOT_VERSION='0.11.4'
RIOT_VERSION='0.12.1'
RIOT_FILENAME="riot-v${RIOT_VERSION}"
RIOT_HASH='792b8eb398ec08c6f32f64b27f92d31d658c6d2338c1e43c84136f25f64d1cb2'
RIOT_HASH='f6fc2df335af2abcf9fa1329819d20b4d1a0fc8a94a8f087b5f09941f2d5c44a'
RIOT_DOWNLOAD_URL="https://github.com/vector-im/riot-web/releases/download/v${RIOT_VERSION}"
RIOT_ONION_PORT=8115
RIOT_ONION_HOSTNAME=

View File

@ -171,9 +171,13 @@ function restore_local_rss {
restore_database ttrss ${RSS_READER_DOMAIN_NAME}
if [ -d /etc/share/tt-rss ]; then
if [ -d /root/tempttrss/etc/share/tt-rss ]; then
rm -rf /etc/share/tt-rss
mv /root/tempttrss/etc/share/tt-rss /etc/share/
if [ -d $temp_restore_dir/etc/share/tt-rss ]; then
if [ -d $temp_restore_dir/etc/share/tt-rss ]; then
rm -rf /etc/share/tt-rss
mv $temp_restore_dir/etc/share/tt-rss /etc/share/
else
cp -r $temp_restore_dir/* /etc/share/tt-rss/
fi
if [ ! "$?" = "0" ]; then
function_check set_user_permissions
set_user_permissions
@ -230,6 +234,7 @@ function backup_remote_rss {
}
function restore_remote_rss {
temp_restore_dir=/root/tempttrss
if grep -q "rss reader domain" $COMPLETION_FILE; then
echo $"Restoring ttrss"
function_check restore_database_from_friend
@ -240,8 +245,12 @@ function restore_remote_rss {
restore_database_from_friend ttrss ${RSS_READER_DOMAIN_NAME}
if [ -d /etc/share/tt-rss ]; then
rm -rf /etc/share/tt-rss
mv /root/tempttrss/etc/share/tt-rss /etc/share/
if [ -d $temp_restore_dir/etc/share/tt-rss ]; then
rm -rf /etc/share/tt-rss
mv $temp_restore_dir/etc/share/tt-rss /etc/share/
else
cp -r $temp_restore_dir/* /etc/share/tt-rss/
fi
if [ ! "$?" = "0" ]; then
exit 6391
fi

View File

@ -144,8 +144,13 @@ function restore_local_scuttlebot {
temp_restore_dir=/root/tempscuttlebot
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir scuttlebot
cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
if [ -d $temp_restore_dir/etc/scuttlebot/.ssb ]; then
cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
else
cp -r $temp_restore_dir/* /etc/scuttlebot/.ssb/*
fi
systemctl start scuttlebot
rm -rf $temp_restore_dir
fi
}
@ -164,8 +169,13 @@ function restore_remote_scuttlebot {
temp_restore_dir=/root/tempscuttlebot
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir scuttlebot
cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
if [ -d $temp_restore_dir/etc/scuttlebot/.ssb ]; then
cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
else
cp -r $temp_restore_dir/* /etc/scuttlebot/.ssb/*
fi
systemctl start scuttlebot
rm -rf $temp_restore_dir
fi
}

View File

@ -145,7 +145,11 @@ function restore_local_sip {
temp_restore_dir=/root/tempsip
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir sip
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
else
cp -f $temp_restore_dir/sipwitch.conf /etc/sipwitch.conf
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
@ -173,7 +177,23 @@ function backup_remote_sip {
}
function restore_remote_sip {
echo -n ''
temp_restore_dir=/root/tempsip
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir sip
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
else
cp -f $temp_restore_dir/sipwitch.conf /etc/sipwitch.conf
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
set_user_permissions
backup_unmount_drive
exit 3679
fi
rm -rf $temp_restore_dir
systemctl restart sipwitch
}
function remove_sip {

View File

@ -286,7 +286,13 @@ function restore_local_syncthing {
echo $"Restoring syncthing configuration"
function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir}config syncthingconfig
cp -r ${temp_restore_dir}config/* /
#cp -r ${temp_restore_dir}config/* /
if [ ! -d /root/.config/syncthing ]; then
mkdir -p /root/.config/syncthing
fi
cp -r ${temp_restore_dir}config/* /root/.config/syncthing/
if [ ! "$?" = "0" ]; then
set_user_permissions
backup_unmount_drive
@ -300,7 +306,13 @@ function restore_local_syncthing {
if [ -d $USB_MOUNT/backup/syncthingshared ]; then
echo $"Restoring syncthing shared files"
restore_directory_from_usb ${temp_restore_dir}shared syncthingshared
cp -r ${temp_restore_dir}shared/* /
#cp -r ${temp_restore_dir}shared/* /
if [ ! -d /var/lib/syncthing/SyncShared ]; then
mkdir -p /var/lib/syncthing/SyncShared
fi
cp -r ${temp_restore_dir}shared/* /var/lib/syncthing/SyncShared/
if [ ! "$?" = "0" ]; then
set_user_permissions
backup_unmount_drive
@ -320,7 +332,11 @@ function restore_local_syncthing {
fi
echo $"Restoring syncthing files for $USERNAME"
restore_directory_from_usb ${temp_restore_dir} syncthing/$USERNAME
cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/
if [ -d ${temp_restore_dir}/home/$USERNAME/Sync ]; then
cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/
else
cp -r ${temp_restore_dir}/* /home/$USERNAME/Sync/
fi
if [ ! "$?" = "0" ]; then
rm -rf ${temp_restore_dir}
set_user_permissions
@ -399,7 +415,11 @@ function restore_remote_syncthing {
temp_restore_dir=/root/tempsyncthingconfig
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir syncthingconfig
cp -r $temp_restore_dir/* /
#cp -r $temp_restore_dir/* /
if [ ! -d /root/.config/syncthing ]; then
mkdir -p /root/.config/syncthing
fi
cp -r ${temp_restore_dir}config/* /root/.config/syncthing/
if [ ! "$?" = "0" ]; then
systemctl start syncthing
systemctl start cron
@ -413,7 +433,11 @@ function restore_remote_syncthing {
temp_restore_dir=/root/tempsyncthingshared
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir syncthingshared
cp -r $temp_restore_dir/* /
#cp -r $temp_restore_dir/* /
if [ ! -d /var/lib/syncthing/SyncShared ]; then
mkdir -p /var/lib/syncthing/SyncShared
fi
cp -r ${temp_restore_dir}shared/* /var/lib/syncthing/SyncShared/
if [ ! "$?" = "0" ]; then
systemctl start syncthing
systemctl start cron
@ -433,7 +457,11 @@ function restore_remote_syncthing {
temp_restore_dir=/root/tempsyncthing
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir syncthing/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/Sync /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/Sync ]; then
cp -r $temp_restore_dir/home/$USERNAME/Sync /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/Sync/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
systemctl start syncthing

View File

@ -298,13 +298,22 @@ function restore_local_tahoelafs {
systemctl stop tahoelafs-client
temp_restore_dir=/root/temptahoelafs
restore_directory_from_usb $temp_restore_dir tahoelafs
mv $TAHOE_DIR ${TAHOE_DIR}-old
cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR
if [ -d $temp_restore_dir$TAHOE_DIR ]; then
mv $TAHOE_DIR ${TAHOE_DIR}-old
cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR
else
cp -r $temp_restore_dir/* $TAHOE_DIR/
fi
if [ ! "$?" = "0" ]; then
mv ${TAHOE_DIR}-old $TAHOE_DIR
if [ -d ${TAHOE_DIR}-old ]; then
mv ${TAHOE_DIR}-old $TAHOE_DIR
fi
exit 246833
fi
rm -rf ${TAHOE_DIR}-old
if [ -d ${TAHOE_DIR}-old ]; then
rm -rf ${TAHOE_DIR}-old
fi
rm -rf $temp_restore_dir
chown -R tahoelafs:debian-tor $TAHOE_DIR
systemctl start tahoelafs-client
systemctl start tahoelafs-storage
@ -331,13 +340,22 @@ function restore_remote_tahoelafs {
systemctl stop tahoelafs-client
temp_restore_dir=/root/temptahoelafs
restore_directory_from_friend $temp_restore_dir tahoelafs
mv $TAHOE_DIR ${TAHOE_DIR}-old
cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR
if [ -d $temp_restore_dir$TAHOE_DIR ]; then
mv $TAHOE_DIR ${TAHOE_DIR}-old
cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR
else
cp -r $temp_restore_dir/* $TAHOE_DIR/
fi
if [ ! "$?" = "0" ]; then
mv ${TAHOE_DIR}old $TAHOE_DIR
if [ -d ${$TAHOE_DIR}-old ]; then
mv ${TAHOE_DIR}-old $TAHOE_DIR
fi
exit 623925
fi
rm -rf ${$TAHOE_DIR}-old
if [ -d ${$TAHOE_DIR}-old ]; then
rm -rf ${$TAHOE_DIR}-old
fi
rm -rf $temp_restore_dir
chown -R tahoelafs:debian-tor $TAHOE_DIR
systemctl start tahoelafs-client
systemctl start tahoelafs-storage

View File

@ -213,7 +213,8 @@ function restore_local_tox {
if [ -d $USB_MOUNT/backup/tox ]; then
echo $"Restoring Tox node settings"
function_check restore_directory_from_usb
restore_directory_from_usb / tox
#restore_directory_from_usb / tox
restore_directory_from_usb /var/lib/tox-bootstrapd tox
if [ ! "$?" = "0" ]; then
function_check set_user_permissions
set_user_permissions
@ -250,7 +251,8 @@ function restore_remote_tox {
if [ -d $SERVER_DIRECTORY/backup/tox ]; then
echo $"Restoring Tox node settings"
function_check restore_directory_from_friend
restore_directory_from_friend / tox
#restore_directory_from_friend / tox
restore_directory_from_friend /var/lib/tox-bootstrapd tox
if [ ! "$?" = "0" ]; then
exit 93653
fi

View File

@ -249,18 +249,14 @@ function restore_local_turtl {
if [ $TURTL_DOMAIN_NAME ]; then
temp_restore_dir=/root/tempturtl
restore_directory_from_usb $temp_restore_dir turtl
if [ -d $TURTL_BASE_DIR ]; then
if [ -d /etc/turtl_previous ]; then
rm -rf /etc/turtl_previous
fi
mv $TURTL_BASE_DIR /etc/turtl_previous
if [ -d ${temp_restore_dir}/etc/turtl ]; then
cp -r ${temp_restore_dir}/etc/turtl/* /etc/turtl/
else
cp -r ${temp_restore_dir}/* /etc/turtl/
fi
temp_source_dir=$(find ${temp_restore_dir} -name turtl)
cp -r ${temp_source_dir} /etc/
if [ ! "$?" = "0" ]; then
if [ -d /etc/turtl_previous ]; then
mv /etc/turtl_previous $TURTL_BASE_DIR
fi
set_user_permissions
backup_unmount_drive
exit 36723
@ -270,18 +266,14 @@ function restore_local_turtl {
temp_restore_dir=/root/temprethinkdb
restore_directory_from_usb $temp_restore_dir rethinkdb
if [ -d /var/lib/rethinkdb ]; then
if [ -d /var/lib/previous_rethinkdb ]; then
rm -rf /var/lib/previous_rethinkdb
fi
mv /var/lib/rethinkdb /var/lib/previous_rethinkdb
if [ -d ${temp_restore_dir}/var/lib/rethinkdb ]; then
cp -r ${temp_restore_dir}/var/lib/rethinkdb/* /var/lib/rethinkdb/
else
cp -r ${temp_restore_dir}/* /var/lib/rethinkdb/
fi
temp_source_dir=$(find ${temp_restore_dir} -name rethinkdb)
cp -r ${temp_source_dir} /var/lib/
if [ ! "$?" = "0" ]; then
if [ -d /var/lib/previous_rethinkdb ]; then
mv /var/lib/previous_rethinkdb /var/lib/rethinkdb
fi
set_user_permissions
backup_unmount_drive
exit 378324
@ -319,18 +311,18 @@ function restore_remote_turtl {
mkdir $temp_restore_dir
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir turtl
if [ -d $TURTL_BASE_DIR ]; then
if [ -d /etc/turtl_previous ]; then
rm -rf /etc/turtl_previous
fi
mv $TURTL_BASE_DIR /etc/turtl_previous
if [ -d ${temp_restore_dir}/etc/turtl ]; then
cp -r ${temp_restore_dir}/etc/turtl/* /etc/turtl/
else
cp -r ${temp_restore_dir}/* /etc/turtl/
fi
temp_source_dir=$(find ${temp_restore_dir} -name turtl)
cp -r ${temp_source_dir} /etc/
if [ ! "$?" = "0" ]; then
if [ -d /etc/turtl_previous ]; then
mv /etc/turtl_previous $TURTL_BASE_DIR
fi
set_user_permissions
exit 37823
fi
rm -rf ${temp_restore_dir}
@ -339,18 +331,15 @@ function restore_remote_turtl {
mkdir $temp_restore_dir
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir rethinkdb
if [ -d /var/lib/rethinkdb ]; then
if [ -d /var/lib/previous_rethinkdb ]; then
rm -rf /var/lib/previous_rethinkdb
fi
mv /var/lib/rethinkdb /var/lib/previous_rethinkdb
if [ -d ${temp_restore_dir}/var/lib/rethinkdb ]; then
cp -r ${temp_restore_dir}/var/lib/rethinkdb/* /var/lib/rethinkdb/
else
cp -r ${temp_restore_dir}/* /var/lib/rethinkdb/
fi
temp_source_dir=$(find ${temp_restore_dir} -name rethinkdb)
cp -r ${temp_source_dir} /var/lib/
if [ ! "$?" = "0" ]; then
if [ -d /var/lib/previous_rethinkdb ]; then
mv /var/lib/previous_rethinkdb /var/lib/rethinkdb
fi
set_user_permissions
exit 26783
fi
rm -rf ${temp_restore_dir}

View File

@ -100,7 +100,14 @@ function restore_local_vim {
echo $"Restoring Vim config for $USERNAME"
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir vim/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR ]; then
cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/
else
if [ ! -d /home/$USERNAME/$VIM_TEMP_DIR ]; then
mkdir /home/$USERNAME/$VIM_TEMP_DIR
fi
cp -r $temp_restore_dir/* /home/$USERNAME/$VIM_TEMP_DIR/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
@ -168,7 +175,14 @@ function restore_remote_vim {
echo $"Restoring Vim config for $USERNAME"
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir vim/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR ]; then
cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/
else
if [ ! -d /home/$USERNAME/$VIM_TEMP_DIR ]; then
mkdir /home/$USERNAME/$VIM_TEMP_DIR
fi
cp -r $temp_restore_dir/* /home/$USERNAME/$VIM_TEMP_DIR/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions

View File

@ -134,8 +134,12 @@ function restore_local_wekan {
temp_restore_dir=/root/tempwekan
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir wekan
cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
if [ -d $temp_restore_dir$WEKAN_DIR/data ]; then
cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
else
cp -r $temp_restore_dir/* $WEKAN_DIR/data/
fi
rm -rf $temp_restore_dir
systemctl start wekan
fi
}
@ -177,8 +181,12 @@ function restore_remote_wekan {
temp_restore_dir=/root/tempwekan
function_check restore_directory_from_usb
restore_directory_from_friend $temp_restore_dir wekan
cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
if [ -d $temp_restore_dir$WEKAN_DIR/data ]; then
cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
else
cp -r $temp_restore_dir/* $WEKAN_DIR/data/
fi
rm -rf $temp_restore_dir
systemctl start wekan
fi
}

View File

@ -460,7 +460,11 @@ function restore_local_xmpp {
temp_restore_dir=/root/tempxmpp
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir xmpp
cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
if [ -d $temp_restore_dir/var/lib/prosody ]; then
cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
else
cp -r $temp_restore_dir/* /var/lib/prosody/
fi
if [ ! "$?" = "0" ]; then
function_check set_user_permissions
set_user_permissions
@ -489,7 +493,11 @@ function restore_remote_xmpp {
temp_restore_dir=/root/tempxmpp
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir xmpp
cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
if [ -d $temp_restore_dir/var/lib/prosody ]; then
cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
else
cp -r $temp_restore_dir/* /var/lib/prosody/
fi
if [ ! "$?" = "0" ]; then
exit 725
fi

View File

@ -1065,8 +1065,9 @@ function image_setup_utils {
rm $rootdir/root/sysctl.conf
# all the packages
chroot "$rootdir" apt-get -yq install cryptsetup libgfshare-bin obnam sshpass wget avahi-daemon
chroot "$rootdir" apt-get -yq install avahi-utils avahi-discover connect-proxy openssh-server
chroot "$rootdir" apt-get -yq install cryptsetup libgfshare-bin duplicity sshpass wget
chroot "$rootdir" apt-get -yq install avahi-daemon avahi-utils avahi-discover
chroot "$rootdir" apt-get -yq install connect-proxy openssh-server
chroot "$rootdir" apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
chroot "$rootdir" apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools
chroot "$rootdir" apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
@ -1166,7 +1167,7 @@ function image_setup_utils {
chroot "$rootdir" apt-get -yq install dovecot-imapd
#backup
chroot "$rootdir" apt-get -yq install obnam gnupg
chroot "$rootdir" apt-get -yq install duplicity gnupg
# monkeysphere
#chroot "$rootdir" apt-get -yq install monkeysphere msva-perl

View File

@ -123,8 +123,10 @@ function restore_blocklist {
temp_restore_dir=/root/tempblocklist
restore_directory_from_usb $temp_restore_dir blocklist
if [ -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg ]; then
if [ -d $temp_restore_dir/root/tempbackupblocklist ]; then
cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
else
cp -f $temp_restore_dir/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
fi
rm -rf $temp_restore_dir
@ -146,13 +148,25 @@ function restore_configfiles {
temp_restore_dir=/root/tempconfigfiles
restore_directory_from_usb $temp_restore_dir configfiles
if [ -f $temp_restore_dir/root/.nostore ]; then
if [ ! -f /root/.nostore ]; then
touch /root/.nostore
if [ -d $temp_restore_dir/root ]; then
if [ -f $temp_restore_dir/root/.nostore ]; then
if [ ! -f /root/.nostore ]; then
touch /root/.nostore
fi
else
if [ -f /root/.nostore ]; then
rm /root/.nostore
fi
fi
else
if [ -f /root/.nostore ]; then
rm /root/.nostore
if [ -f $temp_restore_dir/.nostore ]; then
if [ ! -f /root/.nostore ]; then
touch /root/.nostore
fi
else
if [ -f /root/.nostore ]; then
rm /root/.nostore
fi
fi
fi
@ -196,8 +210,14 @@ function restore_configfiles {
fi
# restore nginx password hashes
if [ -f $temp_restore_dir/root/htpasswd ]; then
cp -f $temp_restore_dir/root/htpasswd /etc/nginx/.htpasswd
if [ -d $temp_restore_dir/root ]; then
if [ -f $temp_restore_dir/root/htpasswd ]; then
cp -f $temp_restore_dir/root/htpasswd /etc/nginx/.htpasswd
fi
else
if [ -f $temp_restore_dir/htpasswd ]; then
cp -f $temp_restore_dir/htpasswd /etc/nginx/.htpasswd
fi
fi
rm -rf $temp_restore_dir
@ -238,11 +258,19 @@ function restore_mariadb {
db_pass=$(cat /root/.mariadboriginal)
if [ ${#db_pass} -gt 0 ]; then
echo $"Restore the MariaDB user table"
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
else
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
fi
if [ ! "$?" = "0" ]; then
echo $"Try again using the password obtained from backup"
db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb)
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
else
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
fi
fi
if [ ! "$?" = "0" ]; then
echo "$mysqlsuccess"
@ -269,7 +297,8 @@ function restore_letsencrypt {
fi
if [ -d $USB_MOUNT/backup/letsencrypt ]; then
echo $"Restoring Lets Encrypt settings"
restore_directory_from_usb / letsencrypt
#restore_directory_from_usb / letsencrypt
restore_directory_from_usb /etc/letsencrypt letsencrypt
chgrp -R ssl-cert /etc/letsencrypt
chmod -R g=rX /etc/letsencrypt
fi
@ -284,7 +313,8 @@ function restore_passwordstore {
if [ -d $USB_MOUNT/backup/passwordstore ]; then
store_original_mariadb_password
echo $"Restoring password store"
restore_directory_from_usb / passwordstore
#restore_directory_from_usb / passwordstore
restore_directory_from_usb /root/.passwords passwordstore
fi
}
@ -296,7 +326,8 @@ function restore_tor {
fi
if [ -d $USB_MOUNT/backup/tor ]; then
echo $"Restoring Tor settings"
restore_directory_from_usb / tor
#restore_directory_from_usb / tor
restore_directory_from_usb /var/lib/tor tor
fi
}
@ -316,15 +347,28 @@ function restore_mutt_settings {
echo $"Restoring Mutt settings for $USERNAME"
temp_restore_dir=/root/tempmutt
restore_directory_from_usb $temp_restore_dir mutt/$USERNAME
if [ -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc ]; then
cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
fi
if [ -f $temp_restore_dir/home/$USERNAME/tempbackup/Muttrc ]; then
cp -f $temp_restore_dir/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
sed -i '/set sidebar_delim/d' /etc/Muttrc
sed -i '/set sidebar_sort/d' /etc/Muttrc
if [ -d $temp_restore_dir/home/$USERNAME/tempbackup ]; then
if [ -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc ]; then
cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
fi
if [ -f $temp_restore_dir/home/$USERNAME/tempbackup/Muttrc ]; then
cp -f $temp_restore_dir/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
sed -i '/set sidebar_delim/d' /etc/Muttrc
sed -i '/set sidebar_sort/d' /etc/Muttrc
fi
else
if [ -f $temp_restore_dir/.muttrc ]; then
cp -f $temp_restore_dir/.muttrc /home/$USERNAME/.muttrc
sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
fi
if [ -f $temp_restore_dir/Muttrc ]; then
cp -f $temp_restore_dir/Muttrc /etc/Muttrc
sed -i '/set sidebar_delim/d' /etc/Muttrc
sed -i '/set sidebar_sort/d' /etc/Muttrc
fi
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
@ -353,7 +397,11 @@ function restore_gpg {
echo $"Restoring gnupg settings for $USERNAME"
temp_restore_dir=/root/tempgnupg
restore_directory_from_usb $temp_restore_dir gnupg/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.gnupg /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.gnupg ]; then
cp -r $temp_restore_dir/home/$USERNAME/.gnupg /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.gnupg/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
set_user_permissions
@ -393,7 +441,11 @@ function restore_procmail {
temp_restore_dir=/root/tempprocmail
restore_directory_from_usb $temp_restore_dir procmail/$USERNAME
if [ -d $temp_restore_dir ]; then
cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
else
cp -f $temp_restore_dir/.procmailrc /home/$USERNAME/.procmailrc
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
set_user_permissions
@ -424,7 +476,11 @@ function restore_spamassassin {
echo $"Restoring spamassassin settings for $USERNAME"
temp_restore_dir=/root/tempspamassassin
restore_directory_from_usb $temp_restore_dir spamassassin/$USERNAME
cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME ]; then
cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/
else
cp -rf $temp_restore_dir/* /home/$USERNAME/.spamassassin/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
set_user_permissions
@ -457,7 +513,11 @@ function restore_admin_readme {
temp_restore_dir=/root/tempreadme
restore_directory_from_usb $temp_restore_dir readme
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
else
cp -f $temp_restore_dir/README /home/$ADMIN_USERNAME/README
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
set_user_permissions
@ -484,7 +544,11 @@ function restore_user_ssh_keys {
echo $"Restoring ssh keys for $USERNAME"
temp_restore_dir=/root/tempssh
restore_directory_from_usb $temp_restore_dir ssh/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.ssh ]; then
cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.ssh/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
set_user_permissions
@ -513,7 +577,11 @@ function restore_user_config {
echo $"Restoring config files for $USERNAME"
temp_restore_dir=/root/tempconfig
restore_directory_from_usb $temp_restore_dir config/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.config ]; then
cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.config/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
set_user_permissions
@ -542,7 +610,11 @@ function restore_user_monkeysphere {
echo $"Restoring monkeysphere ids for $USERNAME"
temp_restore_dir=/root/tempmonkeysphere
restore_directory_from_usb $temp_restore_dir monkeysphere/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.monkeysphere ]; then
cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.monkeysphere
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
set_user_permissions
@ -579,7 +651,11 @@ function restore_user_fin {
echo $"Restoring fin files for $USERNAME"
temp_restore_dir=/root/tempfin
restore_directory_from_usb $temp_restore_dir fin/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.fin ]; then
cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.fin/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
set_user_permissions
@ -608,7 +684,11 @@ function restore_user_local {
echo $"Restoring local files for $USERNAME"
temp_restore_dir=/root/templocal
restore_directory_from_usb $temp_restore_dir local/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.local ]; then
cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.local/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
set_user_permissions
@ -631,7 +711,11 @@ function restore_certs {
echo $"Restoring certificates"
mkdir /root/tempssl
restore_directory_from_usb /root/tempssl ssl
cp -r /root/tempssl/etc/ssl/* /etc/ssl
if [ -d /root/tempssl/etc/ssl ]; then
cp -r /root/tempssl/etc/ssl/* /etc/ssl
else
cp -r /root/tempssl/* /etc/ssl/
fi
if [ ! "$?" = "0" ]; then
set_user_permissions
backup_unmount_drive
@ -686,7 +770,11 @@ function restore_personal_settings {
if [ -d /home/$USERNAME/personal ]; then
rm -rf /home/$USERNAME/personal
fi
mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/personal ]; then
mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME
else
cp -r $temp_restore_dir/* /home/$USERNAME/personal/
fi
if [ ! "$?" = "0" ]; then
set_user_permissions
backup_unmount_drive
@ -709,7 +797,11 @@ function restore_mailing_list {
echo $"Restoring public mailing list"
temp_restore_dir=/root/tempmailinglist
restore_directory_from_usb $temp_restore_dir mailinglist
cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj
if [ -d $temp_restore_dir/root/spool/mlmmj ]; then
cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj
else
cp -r $temp_restore_dir/* /var/spool/mlmmj/
fi
if [ ! "$?" = "0" ]; then
set_user_permissions
backup_unmount_drive
@ -738,11 +830,15 @@ function restore_email {
if [ ! -d /home/$USERNAME/Maildir ]; then
mkdir /home/$USERNAME/Maildir
fi
tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
if [ -d $temp_restore_dir/root/tempbackupemail/$USERNAME ]; then
tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
else
tar -xzvf $temp_restore_dir/maildir.tar.gz -C /
fi
if [ ! "$?" = "0" ]; then
set_user_permissions
backup_unmount_drive
exit 927
exit 9276382
fi
rm -rf $temp_restore_dir
fi

View File

@ -113,10 +113,11 @@ function restore_blocklist {
echo $"Restoring blocklist"
temp_restore_dir=/root/tempblocklist
restore_directory_from_friend $temp_restore_dir blocklist
restore_directory_from_usb $temp_restore_dir blocklist
if [ -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg ]; then
if [ -d $temp_restore_dir/root/tempbackupblocklist ]; then
cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
else
cp -f $temp_restore_dir/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
fi
rm -rf $temp_restore_dir
@ -136,13 +137,25 @@ function restore_configfiles {
temp_restore_dir=/root/tempconfigfiles
restore_directory_from_friend $temp_restore_dir configfiles
if [ -f $temp_restore_dir/root/.nostore ]; then
if [ ! -f /root/.nostore ]; then
touch /root/.nostore
if [ -d $temp_restore_dir/root ]; then
if [ -f $temp_restore_dir/root/.nostore ]; then
if [ ! -f /root/.nostore ]; then
touch /root/.nostore
fi
else
if [ -f /root/.nostore ]; then
rm /root/.nostore
fi
fi
else
if [ -f /root/.nostore ]; then
rm /root/.nostore
if [ -f $temp_restore_dir/.nostore ]; then
if [ ! -f /root/.nostore ]; then
touch /root/.nostore
fi
else
if [ -f /root/.nostore ]; then
rm /root/.nostore
fi
fi
fi
@ -214,11 +227,19 @@ function restore_mariadb {
db_pass=$(cat /root/.mariadboriginal)
if [ ${#db_pass} -gt 0 ]; then
echo $"Restore the MariaDB user table"
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
else
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
fi
if [ ! "$?" = "0" ]; then
echo $"Try again using the password obtained from backup"
db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb)
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
else
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
fi
fi
if [ ! "$?" = "0" ]; then
echo "$mysqlsuccess"
@ -242,7 +263,7 @@ function restore_letsencrypt {
fi
if [ -d $SERVER_DIRECTORY/backup/letsencrypt ]; then
echo $"Restoring Lets Encrypt settings"
restore_directory_from_friend / letsencrypt
restore_directory_from_friend /etc/letsencrypt letsencrypt
fi
}
@ -255,7 +276,7 @@ function restore_passwordstore {
if [ -d $SERVER_DIRECTORY/backup/passwordstore ]; then
store_original_mariadb_password
echo $"Restoring password store"
restore_directory_from_friend / passwordstore
restore_directory_from_friend /root/.passwords passwordstore
fi
}
@ -267,7 +288,7 @@ function restore_tor {
fi
if [ -d $SERVER_DIRECTORY/backup/tor ]; then
echo $"Restoring Tor settings"
restore_directory_from_friend / tor
restore_directory_from_friend /var/lib/tor tor
fi
}
@ -287,15 +308,28 @@ function restore_mutt_settings {
echo $"Restoring Mutt settings for $USERNAME"
temp_restore_dir=/root/tempmutt
restore_directory_from_friend ${temp_restore_dir} mutt/$USERNAME
if [ -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc ]; then
cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
fi
if [ -f ${temp_restore_dir}/home/$USERNAME/tempbackup/Muttrc ]; then
cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
sed -i '/set sidebar_delim/d' /etc/Muttrc
sed -i '/set sidebar_sort/d' /etc/Muttrc
if [ -d ${temp_restore_dir}/home/$USERNAME/tempbackup ]; then
if [ -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc ]; then
cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
fi
if [ -f ${temp_restore_dir}/home/$USERNAME/tempbackup/Muttrc ]; then
cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
sed -i '/set sidebar_delim/d' /etc/Muttrc
sed -i '/set sidebar_sort/d' /etc/Muttrc
fi
else
if [ -f ${temp_restore_dir}/.muttrc ]; then
cp -f ${temp_restore_dir}/.muttrc /home/$USERNAME/.muttrc
sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
fi
if [ -f ${temp_restore_dir}/Muttrc ]; then
cp -f ${temp_restore_dir}/Muttrc /etc/Muttrc
sed -i '/set sidebar_delim/d' /etc/Muttrc
sed -i '/set sidebar_sort/d' /etc/Muttrc
fi
fi
if [ ! "$?" = "0" ]; then
rm -rf ${temp_restore_dir}
@ -322,7 +356,11 @@ function restore_gpg {
echo $"Restoring gnupg settings for $USERNAME"
temp_restore_dir=/root/tempgnupg
restore_directory_from_friend ${temp_restore_dir} gnupg/$USERNAME
cp -r ${temp_restore_dir}/home/$USERNAME/.gnupg /home/$USERNAME/
if [ -d ${temp_restore_dir}/home/$USERNAME/.gnupg ]; then
cp -r ${temp_restore_dir}/home/$USERNAME/.gnupg /home/$USERNAME/
else
cp -r ${temp_restore_dir}/* /home/$USERNAME/.gnupg/
fi
if [ ! "$?" = "0" ]; then
rm -rf ${temp_restore_dir}
exit 276
@ -356,7 +394,11 @@ function restore_procmail {
echo $"Restoring procmail settings for $USERNAME"
temp_restore_dir=/root/tempprocmail
restore_directory_from_friend ${temp_restore_dir} procmail/$USERNAME
cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
if [ -d ${temp_restore_dir}/home/$USERNAME/tempbackup ]; then
cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
else
cp -f ${temp_restore_dir}/.procmailrc /home/$USERNAME/.procmailrc
fi
if [ ! "$?" = "0" ]; then
rm -rf ${temp_restore_dir}
exit 276
@ -383,7 +425,11 @@ function restore_spamassassin {
echo $"Restoring spamassassin settings for $USERNAME"
temp_restore_dir=/root/tempspamassassin
restore_directory_from_friend $temp_restore_dir spamassassin/$USERNAME
cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME ]; then
cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/
else
cp -rf $temp_restore_dir/* /home/$USERNAME/.spamassassin/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
exit 276
@ -404,7 +450,11 @@ function restore_admin_readme {
echo $"Restoring README"
temp_restore_dir=/root/tempreadme
restore_directory_from_friend $temp_restore_dir readme
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
else
cp -f $temp_restore_dir/README /home/$ADMIN_USERNAME/README
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
exit 276
@ -429,7 +479,11 @@ function restore_ssh_keys {
echo $"Restoring ssh keys for $USERNAME"
temp_restore_dir=/root/tempssh
restore_directory_from_friend $temp_restore_dir ssh/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.ssh ]; then
cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.ssh/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
exit 664
@ -456,7 +510,11 @@ function restore_user_config {
echo $"Restoring config files for $USERNAME"
temp_restore_dir=/root/tempconfig
restore_directory_from_friend $temp_restore_dir config/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME ]; then
cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.config/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
exit 664
@ -483,7 +541,11 @@ function restore_user_monkeysphere {
echo $"Restoring monkeysphere ids for $USERNAME"
temp_restore_dir=/root/tempmonkeysphere
restore_directory_from_friend $temp_restore_dir monkeysphere/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.monkeysphere ]; then
cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.monkeysphere/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
exit 664
@ -518,7 +580,11 @@ function restore_user_fin {
echo $"Restoring fin files for $USERNAME"
temp_restore_dir=/root/tempfin
restore_directory_from_friend $temp_restore_dir fin/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.fin ]; then
cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.fin/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
exit 664
@ -545,7 +611,11 @@ function restore_user_local {
echo $"Restoring local files for $USERNAME"
temp_restore_dir=/root/templocal
restore_directory_from_friend $temp_restore_dir local/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/
if [ -d $temp_restore_dir/home/$USERNAME/.local ]; then
cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.local/
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
exit 664
@ -565,7 +635,11 @@ function restore_certs {
if [ -d $SERVER_DIRECTORY/backup/ssl ]; then
echo $"Restoring certificates"
restore_directory_from_friend /root/tempssl ssl
cp -r /root/tempssl/etc/ssl/* /etc/ssl
if [ -d /root/tempssl/etc/ssl ]; then
cp -r /root/tempssl/etc/ssl/* /etc/ssl
else
cp -r /root/tempssl/* /etc/ssl/
fi
if [ ! "$?" = "0" ]; then
exit 276
fi
@ -614,12 +688,16 @@ function restore_personal_settings {
echo $"Restoring personal settings for $USERNAME"
temp_restore_dir=/root/temppersonal
restore_directory_from_friend $temp_restore_dir personal/$USERNAME
if [ -d /home/$USERNAME/personal ]; then
rm -rf /home/$USERNAME/personal
if [ -d $temp_restore_dir/home/$USERNAME/personal ]; then
if [ -d /home/$USERNAME/personal ]; then
rm -rf /home/$USERNAME/personal
fi
mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME
else
cp -r $temp_restore_dir/* /home/$USERNAME/personal/
fi
mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME
if [ ! "$?" = "0" ]; then
exit 184
exit 18437643
fi
rm -rf $temp_restore_dir
fi
@ -637,7 +715,11 @@ function restore_mailing_list {
echo $"Restoring public mailing list"
temp_restore_dir=/root/tempmailinglist
restore_directory_from_friend $temp_restore_dir mailinglist
cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj
if [ -d $temp_restore_dir/root/spool/mlmmj ]; then
cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj
else
cp -r $temp_restore_dir/* /var/spool/mlmmj/
fi
if [ ! "$?" = "0" ]; then
exit 526
fi
@ -664,7 +746,11 @@ function restore_email {
if [ ! -d /home/$USERNAME/Maildir ]; then
mkdir /home/$USERNAME/Maildir
fi
tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
if [ -d $temp_restore_dir/root/tempbackupemail/$USERNAME ]; then
tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
else
tar -xzvf $temp_restore_dir/maildir.tar.gz -C /
fi
if [ ! "$?" = "0" ]; then
exit 927
fi

View File

@ -13,7 +13,7 @@
# License
# =======
#
# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
# Copyright (C) 2014-2017 Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@ -34,6 +34,21 @@ SUSPENDED_SITE=
# Dummy password used for the backup key
BACKUP_DUMMY_PASSWORD='backup'
BACKUP_TEMP_DIRECTORY=/root/.backuptemp
BACKUP_GPG_OPTIONS="--pinentry-mode loopback"
function create_backups_temp_directory {
if [ ! -d $BACKUP_TEMP_DIRECTORY ]; then
mkdir $BACKUP_TEMP_DIRECTORY
fi
}
function remove_backups_temp_directory {
if [ -d $BACKUP_TEMP_DIRECTORY ]; then
rm -rf $BACKUP_TEMP_DIRECTORY
fi
}
function suspend_site {
# suspends a given website
SUSPENDED_SITE="$1"
@ -247,6 +262,71 @@ function set_obnam_client_name {
echo "client-name = ${PROJECT_NAME}" >> /etc/obnam.conf
}
function backup_directory_to_usb_duplicity {
create_backups_temp_directory
echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
if [ ! "$?" = "0" ]; then
umount $USB_MOUNT
rm -rf $USB_MOUNT
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu ${1}/*
rm -rf ${1}
fi
function_check restart_site
restart_site
remove_backups_temp_directory
exit 8352925
fi
if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
if [ ! "$?" = "0" ]; then
umount $USB_MOUNT
rm -rf $USB_MOUNT
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu ${1}/*
rm -rf ${1}
fi
function_check restart_site
restart_site
remove_backups_temp_directory
exit 683252
fi
fi
remove_backups_temp_directory
}
function backup_directory_to_usb_obnam {
set_obnam_client_name
echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
echo "$BACKUP_DUMMY_PASSWORD" | obnam verify -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
if [ ! "$?" = "0" ]; then
umount $USB_MOUNT
rm -rf $USB_MOUNT
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu ${1}/*
rm -rf ${1}
fi
function_check restart_site
restart_site
exit 683252
fi
fi
echo "$BACKUP_DUMMY_PASSWORD" | obnam forget --keep=30d -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID
if [ ! "$?" = "0" ]; then
umount $USB_MOUNT
rm -rf $USB_MOUNT
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu ${1}/*
rm -rf ${1}
fi
function_check restart_site
restart_site
exit 7
fi
}
function backup_directory_to_usb {
if [ ! -d ${1} ]; then
echo $"WARNING: directory does not exist: ${1}"
@ -263,35 +343,10 @@ function backup_directory_to_usb {
if [ ! -d $USB_MOUNT/backup/${2} ]; then
mkdir -p $USB_MOUNT/backup/${2}
fi
set_obnam_client_name
echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
echo "$BACKUP_DUMMY_PASSWORD" | obnam verify -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
if [ ! "$?" = "0" ]; then
umount $USB_MOUNT
rm -rf $USB_MOUNT
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu ${1}/*
rm -rf ${1}
fi
function_check restart_site
restart_site
exit 683252
fi
fi
echo "$BACKUP_DUMMY_PASSWORD" | obnam forget --keep=30d -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID
if [ ! "$?" = "0" ]; then
umount $USB_MOUNT
rm -rf $USB_MOUNT
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu ${1}/*
rm -rf ${1}
fi
function_check restart_site
restart_site
exit 7
fi
backup_directory_to_usb_duplicity ${1} ${2}
#backup_directory_to_usb_obnam ${1} ${2}
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu ${1}/*
rm -rf ${1}
@ -299,22 +354,49 @@ function backup_directory_to_usb {
fi
}
function restore_directory_from_usb_obnam {
set_obnam_client_name
echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $USB_MOUNT/backup/${2} --to ${1}
}
function restore_directory_from_usb_duplicity {
create_backups_temp_directory
PASSPHRASE="$BACKUP_DUMMY_PASSWORD" duplicity restore --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --force file://$USB_MOUNT/backup/${2} ${1}
if [ ! "$?" = "0" ]; then
echo "WARNING: failed to restore $USB_MOUNT/backup/${2} to ${1}"
fi
PASSPHRASE=
remove_backups_temp_directory
}
function restore_directory_from_usb {
if [ ! ${1} ]; then
echo "obnam restore -r $USB_MOUNT/backup/${2} --to ${1}"
echo "$USB_MOUNT/backup/${2} -> ${1}"
echo $'No restore destination given'
return
fi
if [ ! ${2} ]; then
echo "obnam restore -r $USB_MOUNT/backup/${2} --to ${1}"
echo "$USB_MOUNT/backup/${2} -> ${1}"
echo $'No restore source given'
return
fi
if [ ! -d ${1} ]; then
mkdir ${1}
fi
restore_directory_from_usb_duplicity ${1} ${2}
#restore_directory_from_usb_obnam ${1} ${2}
}
function restore_directory_from_friend_obnam {
set_obnam_client_name
echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $USB_MOUNT/backup/${2} --to ${1}
echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $SERVER_DIRECTORY/backup/${2} --to ${1}
}
function restore_directory_from_friend_duplicity {
create_backups_temp_directory
PASSPHRASE="$BACKUP_DUMMY_PASSWORD" duplicity restore --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --force file://$SERVER_DIRECTORY/backup/${2} ${1}
PASSPHRASE=
remove_backups_temp_directory
}
function restore_directory_from_friend {
@ -331,8 +413,8 @@ function restore_directory_from_friend {
if [ ! -d ${1} ]; then
mkdir ${1}
fi
set_obnam_client_name
echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $SERVER_DIRECTORY/backup/${2} --to ${1}
restore_directory_from_friend_duplicity ${1} ${2}
#restore_directory_from_friend_obnam ${1} ${2}
}
function backup_database_to_usb {
@ -357,19 +439,36 @@ function set_user_permissions {
done
}
function backup_directory_to_friend {
BACKUP_KEY_EXISTS=$(gpg --list-keys "$ADMIN_NAME (backup key)")
function backup_directory_to_friend_duplicity {
create_backups_temp_directory
echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
if [ ! "$?" = "0" ]; then
echo $"Backup key could not be found"
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu ${1}/*
rm -rf ${1}
fi
function_check restart_site
restart_site
exit 43382
remove_backups_temp_directory
exit 5293526
fi
if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
if [ ! "$?" = "0" ]; then
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu ${1}/*
rm -rf ${1}
fi
function_check restart_site
restart_site
remove_backups_temp_directory
exit 683252
fi
fi
remove_backups_temp_directory
}
ADMIN_BACKUP_KEY_ID=$(gpg --list-keys "$ADMIN_NAME (backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
if [ ! -d $SERVER_DIRECTORY/backup/${2} ]; then
mkdir -p $SERVER_DIRECTORY/backup/${2}
fi
function backup_directory_to_friend_obnam {
set_obnam_client_name
echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
@ -399,6 +498,25 @@ function backup_directory_to_friend {
restart_site
exit 853
fi
}
function backup_directory_to_friend {
BACKUP_KEY_EXISTS=$(gpg --list-keys "$ADMIN_NAME (backup key)")
if [ ! "$?" = "0" ]; then
echo $"Backup key could not be found"
function_check restart_site
restart_site
exit 43382
fi
ADMIN_BACKUP_KEY_ID=$(gpg --list-keys "$ADMIN_NAME (backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
if [ ! -d $SERVER_DIRECTORY/backup/${2} ]; then
mkdir -p $SERVER_DIRECTORY/backup/${2}
fi
backup_directory_to_friend_duplicity ${1} ${2}
#backup_directory_to_friend_obnam ${1} ${2}
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu /root/temp${2}/*
rm -rf /root/temp${2}
@ -510,7 +628,11 @@ function restore_database_from_friend {
echo $"Restoring ${1} database"
local_database_dir=/root/temp${1}data
restore_directory_from_friend ${local_database_dir} ${1}data
if [ ! -f ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data/${1}.sql ]; then
database_file=${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql
if [ ! -f $database_file ]; then
database_file=${local_database_dir}/${restore_app_name}.sql
fi
if [ ! -f $database_file ]; then
echo $"Unable to restore ${1} database"
rm -rf ${local_database_dir}
exit 503
@ -521,21 +643,35 @@ function restore_database_from_friend {
echo "$mysqlsuccess"
exit 964
fi
shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data/*
if [ -d ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data ]; then
shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data/*
else
shred -zu ${local_database_dir}/*.sql
fi
rm -rf ${local_database_dir}
echo $"Restoring ${1} installation"
restore_directory_from_friend /root/temp${1} ${1}
RESTORE_SUBDIR="var"
if [ ${1} ]; then
# create directory to restore to
if [ ! -d /var/www/${2}/htdocs ]; then
mkdir -p /var/www/${2}/htdocs
chown www-data:www-data /var/www/${2}/htdocs
fi
if [ -d /var/www/${2}/htdocs ]; then
if [ -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then
rm -rf /var/www/${2}/htdocs
mv /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs /var/www/${2}/
restore_from_dir=/root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs
if [ ! -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then
restore_from_dir=/root/temp${1}
fi
if [ -d $restore_from_dir ]; then
if [ -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then
rm -rf /var/www/${2}/htdocs
mv $restore_from_dir /var/www/${2}/
else
cp -r $restore_from_dir/* /var/www/${2}/htdocs/
fi
if [ ! "$?" = "0" ]; then
exit 683
fi
@ -567,7 +703,11 @@ function restore_database {
fi
function_check restore_directory_from_usb
restore_directory_from_usb "${local_database_dir}" "${restore_app_name}data"
if [ ! -f /root/temp${restore_app_name}data/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql ]; then
database_file=${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql
if [ ! -f $database_file ]; then
database_file=${local_database_dir}/${restore_app_name}.sql
fi
if [ ! -f $database_file ]; then
echo $"Unable to restore ${restore_app_name} database"
rm -rf ${local_database_dir}
function_check set_user_permissions
@ -577,7 +717,7 @@ function restore_database {
exit 503
fi
keep_database_running
mysqlsuccess=$(mysql -u root --password="$DATABASE_PASSWORD" ${restore_app_name} -o < ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql)
mysqlsuccess=$(mysql -u root --password="$DATABASE_PASSWORD" ${restore_app_name} -o < $database_file)
if [ ! "$?" = "0" ]; then
echo "$mysqlsuccess"
function_check set_user_permissions
@ -586,7 +726,12 @@ function restore_database {
backup_unmount_drive
exit 964
fi
shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/*
if [ -d ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data ]; then
shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/*
else
shred -zu ${local_database_dir}/*.sql
fi
rm -rf ${local_database_dir}
echo $"Restoring ${restore_app_name} installation"
if [ ! -d /root/temp${restore_app_name} ]; then
@ -596,14 +741,24 @@ function restore_database {
restore_directory_from_usb "/root/temp${restore_app_name}" "${restore_app_name}"
RESTORE_SUBDIR="var"
if [ ${restore_app_domain} ]; then
# create directory to restore to
if [ ! -d /var/www/${restore_app_domain}/htdocs ]; then
mkdir -p /var/www/${restore_app_domain}/htdocs
chown www-data:www-data /var/www/${restore_app_domain}/htdocs
fi
if [ -d /var/www/${restore_app_domain}/htdocs ]; then
if [ -d /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs ]; then
rm -rf /var/www/${restore_app_domain}/htdocs
mv /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs /var/www/${restore_app_domain}/
restore_from_dir=/root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs
if [ ! -d $restore_from_dir ]; then
restore_from_dir=/root/temp${restore_app_name}
fi
if [ -d $restore_from_dir ]; then
if [ -d /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs ]; then
rm -rf /var/www/${restore_app_domain}/htdocs
mv $restore_from_dir /var/www/${restore_app_domain}/
else
cp -r $restore_from_dir/* /var/www/${restore_app_domain}/htdocs/
fi
if [ ! "$?" = "0" ]; then
set_user_permissions
backup_unmount_drive

95
src/freedombone-utils-guile Executable file
View File

@ -0,0 +1,95 @@
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Recent version of guile
#
# License
# =======
#
# Copyright (C) 2017 Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
GUILE_VERSION='2.2.0'
GUILE_HASH='c707b9cf6f97ecca3a4e3e704e62b83f95f1aec28ed1535f5d0a1d36af07a015'
EIGHTSYNC_REPO="git://git.savannah.gnu.org/8sync.git"
EIGHTSYNC_COMMIT='8cbb7f22227c0afdd3b0bd758ebec0efba2fa1e1'
function install_8sync {
apt-get -qy install flex libunistring-dev libgc-dev autoconf texinfo
if [ ! -d $INSTALL_DIR ]; then
mkdir $INSTALL_DIR
fi
cd $INSTALL_DIR
git_clone $EIGHTSYNC_REPO $INSTALL_DIR/eightsync
cd $INSTALL_DIR/eightsync
git checkout ${EIGHTSYNC_COMMIT} -b ${EIGHTSYNC_COMMIT}
export GUILE_BASE_PATH=/opt/guile-${GUILE_VERSION}
export GUILE_CFLAGS="-I${GUILE_BASE_PATH}/include"
export GUILE_LIBS="-L${GUILE_BASE_PATH}/lib -lguile -lqthreads -ldl -ltermcap -lsocket -lnsl -lm"
./bootstrap.sh
configure
make
make install
}
function install_guile {
# Currently this only works for x86_64
read_config_param ARCHITECTURE
if [[ ${ARCHITECTURE} != "x86_64" ]]; then
return
fi
GUILE_ARCH='x86_64'
apt-get -qy install flex libunistring-dev libgc-dev autoconf texinfo lzip wget
if [ ! -d $INSTALL_DIR ]; then
mkdir $INSTALL_DIR
fi
cd $INSTALL_DIR
if [ ! -f guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz ]; then
wget https://ftp.gnu.org/gnu/guile/guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz
fi
if [ ! -f guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz ]; then
echo 'Unable to download guile pack'
exit 6735238
fi
CURR_GUILE_HASH=$(sha256sum guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz | awk -F ' ' '{print $1}')
if [[ "$CURR_GUILE_HASH" != "$GUILE_HASH" ]]; then
echo 'Guile hash does not match'
exit 7237625
fi
cd /
tar xvf $INSTALL_DIR/guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz
if [ ! -d /opt/guile-${GUILE_VERSION}/bin ]; then
echo 'Guile was not installed'
exit 825269
fi
echo "export GUILE_PATH=/opt/guile-${GUILE_VERSION}/bin" >> ~/.bashrc
echo 'export PATH=$PATH:$GUILE_PATH' >> ~/.bashrc
}
# NOTE: deliberately no exit 0

View File

@ -260,7 +260,7 @@ function initial_setup {
apt-get -yq dist-upgrade
apt-get -yq install ca-certificates
apt-get -yq install apt-utils
apt-get -yq install cryptsetup libgfshare-bin obnam sshpass wget avahi-daemon
apt-get -yq install cryptsetup libgfshare-bin duplicity sshpass wget avahi-daemon
apt-get -yq install avahi-utils avahi-discover connect-proxy openssh-server
apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools

View File

@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2017-05-10 Wed 20:25 -->
<!-- 2017-08-23 Wed 19:23 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title>
@ -260,9 +260,13 @@ for the JavaScript code in this tag.
Matrix is a federated communications system, typically for multi-user chat, with end-to-end content security features. You can consider it to be like a modernized version of IRC chat where the crypto and access controls have been built in by default. At present Matrix is really only a creature of the clearnet and so there isn't any way to protect the metadata. Despite the talk of security the lack of metadata defenses make this really only suitable for public communications, similar to microblogging or public IRC channels.
</p>
<div id="outline-container-orgc5ac459" class="outline-2">
<h2 id="orgc5ac459">Installation</h2>
<div class="outline-text-2" id="text-orgc5ac459">
<p>
Another consideration is that since matrix operates on the usual HTTPS port number (443) this may make it difficult for ISPs or governments to censor this type of communications via port blocking without significant blowback.
</p>
<div id="outline-container-orgc78770d" class="outline-2">
<h2 id="orgc78770d">Installation</h2>
<div class="outline-text-2" id="text-orgc78770d">
<p>
Log into your system with:
</p>
@ -282,9 +286,9 @@ Select <b>Add/Remove Apps</b> then <b>matrix</b>. You will then be asked for a d
</div>
</div>
<div id="outline-container-orgd4dad6a" class="outline-2">
<h2 id="orgd4dad6a">Initial setup</h2>
<div class="outline-text-2" id="text-orgd4dad6a">
<div id="outline-container-org5262b52" class="outline-2">
<h2 id="org5262b52">Initial setup</h2>
<div class="outline-text-2" id="text-org5262b52">
<p>
Go to the <b>Administrator control panel</b> and select <b>Passwords</b> then <b>matrix</b>. This will give you the password to initially log in to the system and you can change it later from a client app if needed.
</p>
@ -299,9 +303,9 @@ Other client apps are available but are currently mostly only at the alpha stage
</div>
</div>
<div id="outline-container-org43f1308" class="outline-2">
<h2 id="org43f1308">DNS setup</h2>
<div class="outline-text-2" id="text-org43f1308">
<div id="outline-container-orgd8eede9" class="outline-2">
<h2 id="orgd8eede9">DNS setup</h2>
<div class="outline-text-2" id="text-orgd8eede9">
<p>
It's recommended that you add an SRV record for Matrix to your DNS setup. How you do this will depend upon your dynamic DNS provider and their web interface. On FreeDNS on the subdomains settings in addition to the subdomain which you are using for the matrix server create an extra entry as follows:
</p>