Use official owncloud deb
This commit is contained in:
parent
7b3b37e981
commit
f2728c9780
259
src/freedombone
259
src/freedombone
|
@ -228,14 +228,14 @@ GVM_REPO="https://github.com/moovweb/gvm"
|
|||
GVM_COMMIT='25ea8ae158e2861c92e2b22c458e60840157832f'
|
||||
|
||||
# Domain name for Owncloud installation
|
||||
OWNCLOUD_REPO="https://github.com/owncloud/core"
|
||||
OWNCLOUD_COMMIT='stable9'
|
||||
OWNCLOUD_DOMAIN_NAME=
|
||||
OWNCLOUD_CODE=
|
||||
OWNCLOUD_ONION_PORT=8088
|
||||
OWNCLOUD_ADMIN_PASSWORD=
|
||||
OWNCLOUD_MUSIC_APP_REPO="https://github.com/owncloud/music"
|
||||
OWNCLOUD_MUSIC_APP_COMMIT='0c0e1fadbe31a43f9c98d6a2a7b3960ff881ca0e'
|
||||
OWNCLOUD_PATH=/var/www/owncloud
|
||||
OWNCLOUD_UPGRADE_PATH=/root/owncloud_upgrade
|
||||
|
||||
# Domain name for your wiki
|
||||
WIKI_DOMAIN_NAME=
|
||||
|
@ -616,6 +616,18 @@ function git_pull {
|
|||
fi
|
||||
}
|
||||
|
||||
function remove_database {
|
||||
app_name="$1"
|
||||
if [ ! -d $INSTALL_DIR ]; then
|
||||
mkdir $INSTALL_DIR
|
||||
fi
|
||||
echo "drop database ${app_name};
|
||||
quit" > $INSTALL_DIR/batch.sql
|
||||
chmod 600 $INSTALL_DIR/batch.sql
|
||||
mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
|
||||
shred -zu $INSTALL_DIR/batch.sql
|
||||
}
|
||||
|
||||
function create_database {
|
||||
app_name="$1"
|
||||
app_admin_password="$2"
|
||||
|
@ -6285,7 +6297,7 @@ function install_mariadb {
|
|||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
MARIADB_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
MARIADB_PASSWORD="$(openssl rand -base64 32)"
|
||||
MARIADB_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
|
||||
fi
|
||||
echo "$MARIADB_PASSWORD" > $DATABASE_PASSWORD_FILE
|
||||
chmod 600 $DATABASE_PASSWORD_FILE
|
||||
|
@ -6391,15 +6403,15 @@ function install_owncloud_repo_music_app {
|
|||
fi
|
||||
|
||||
# update to the next commit
|
||||
set_repo_commit /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/apps/music "Owncloud music app commit" "$OWNCLOUD_MUSIC_APP_COMMIT" $OWNCLOUD_MUSIC_APP_REPO
|
||||
set_repo_commit $OWNCLOUD_PATH/apps/music "Owncloud music app commit" "$OWNCLOUD_MUSIC_APP_COMMIT" $OWNCLOUD_MUSIC_APP_REPO
|
||||
|
||||
if grep -Fxq "install_owncloud_repo_music_app" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
|
||||
cd /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/apps
|
||||
cd $OWNCLOUD_PATH/apps
|
||||
git_clone $OWNCLOUD_MUSIC_APP_REPO Music
|
||||
cd /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/apps/Music
|
||||
cd $OWNCLOUD_PATH/apps/Music
|
||||
git checkout $OWNCLOUD_MUSIC_APP_COMMIT -b $OWNCLOUD_MUSIC_APP_COMMIT
|
||||
if ! grep -q "Owncloud music app commit" $COMPLETION_FILE; then
|
||||
echo "Owncloud music app commit:$OWNCLOUD_MUSIC_APP_COMMIT" >> $COMPLETION_FILE
|
||||
|
@ -6464,74 +6476,120 @@ function configure_owncloud_onion_site {
|
|||
if [ ! $OWNCLOUD_DOMAIN_NAME ]; then
|
||||
return
|
||||
fi
|
||||
if [ ! -f /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/config.php ]; then
|
||||
if [ ! -f /var/www/owncloud/config/config.php ]; then
|
||||
return
|
||||
fi
|
||||
if [ ! -f /var/lib/tor/hidden_service_owncloud/hostname ]; then
|
||||
return
|
||||
fi
|
||||
OWNCLOUD_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_owncloud/hostname)
|
||||
if ! grep -q "${OWNCLOUD_ONION_HOSTNAME}" /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/config.php; then
|
||||
if ! grep -q "${OWNCLOUD_ONION_HOSTNAME}" /var/www/owncloud/config/config.php; then
|
||||
sed -i "s|0 => '${OWNCLOUD_DOMAIN_NAME}',|0 => '${OWNCLOUD_DOMAIN_NAME}',
|
||||
1 => '${OWNCLOUD_ONION_HOSTNAME}',|g" /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/config.php
|
||||
1 => '${OWNCLOUD_ONION_HOSTNAME}',|g" /var/www/owncloud/config/config.php
|
||||
sed -i "s|'writable' => false,|'writable' => false,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'path' => '/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/apps',
|
||||
'path' => '/var/www/owncloud/apps',
|
||||
'url' => '/apps',
|
||||
'writable' => false,|g" /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/config.php
|
||||
'writable' => false,|g" /var/www/owncloud/config/config.php
|
||||
echo $'Owncloud configured for onion site'
|
||||
fi
|
||||
}
|
||||
|
||||
function upgrade_owncloud {
|
||||
# upgrades from the debian packaged version to a repo based version
|
||||
# The debian package for Owncloud is likely to be removed in future debian releases
|
||||
function upgrade_owncloud_start {
|
||||
# copies data and config directories to a temporary upgrade directory
|
||||
if [ ! -d /etc/owncloud ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# remove any owncloud entries from completion
|
||||
sed -i 's/install_owncloud.*/d' $COMPLETION_FILE
|
||||
sed -i 's/owncloud.*/d' $COMPLETION_FILE
|
||||
|
||||
# create directories
|
||||
if [ ! -d /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data ]; then
|
||||
mkdir /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data
|
||||
if [ ! -d $OWNCLOUD_UPGRADE_PATH/data ]; then
|
||||
mkdir -p $OWNCLOUD_UPGRADE_PATH/data
|
||||
fi
|
||||
if [ ! -d /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config ]; then
|
||||
mkdir /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config
|
||||
if [ ! -d $OWNCLOUD_UPGRADE_PATH/config ]; then
|
||||
mkdir -p $OWNCLOUD_UPGRADE_PATH/config
|
||||
fi
|
||||
|
||||
# move the data
|
||||
# copy data to the temporary directory
|
||||
if [ -d /var/lib/owncloud/data ]; then
|
||||
# copy users over
|
||||
cp -rf /var/lib/owncloud/data/* /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data/
|
||||
# set ownership to www-data
|
||||
chown -R www-data:www-data /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data
|
||||
cp -rf /var/lib/owncloud/data/* $OWNCLOUD_UPGRADE_PATH/data/
|
||||
fi
|
||||
|
||||
# move the config files
|
||||
# copy the config files to the temporary directory
|
||||
if [ -d /etc/owncloud ]; then
|
||||
# copy users over
|
||||
cp -rf /etc/owncloud/* /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/
|
||||
# set ownership to www-data
|
||||
chown -R www-data:www-data /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config
|
||||
cp -rf /etc/owncloud/* $OWNCLOUD_UPGRADE_PATH/config/
|
||||
fi
|
||||
|
||||
# remove the previous owncloud install
|
||||
apt-get -y remove --purge owncloud
|
||||
|
||||
# ensure directories do not exist
|
||||
rm -rf /etc/owncloud
|
||||
if [ -d /var/lib/owncloud ]; then
|
||||
rm -rf /var/lib/owncloud
|
||||
fi
|
||||
}
|
||||
|
||||
function upgrade_owncloud_finish {
|
||||
# copies data from a temporary upgrade directory to the new
|
||||
# owncloud install
|
||||
if [ ! -d $OWNCLOUD_PATH ]; then
|
||||
return
|
||||
fi
|
||||
if [ ! -d $OWNCLOUD_UPGRADE_PATH ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -d $OWNCLOUD_PATH/data ]; then
|
||||
mkdir $OWNCLOUD_PATH/data
|
||||
fi
|
||||
cp -r $OWNCLOUD_UPGRADE_PATH/data/* $OWNCLOUD_PATH/data/
|
||||
|
||||
if [ ! -f $OWNCLOUD_PATH/config/config.php ]; then
|
||||
if [ ! -f $OWNCLOUD_PATH/config/config.sample.php ]; then
|
||||
echo $'No owncloud configuration sample file found'
|
||||
exit 54289
|
||||
fi
|
||||
cp $OWNCLOUD_PATH/config/config.sample.php $OWNCLOUD_PATH/config/config.php
|
||||
fi
|
||||
|
||||
if [ -f $OWNCLOUD_UPGRADE_PATH/config/config.php ]; then
|
||||
OWNCLOUD_INSTANCE_ID=$(cat config.php | grep "instanceid" | awk -F "'" '{print $4}')
|
||||
OWNCLOUD_PASSWORD_SALT=$(cat config.php | grep "passwordsalt" | awk -F "'" '{print $4}')
|
||||
OWNCLOUD_DATA_DIR=$(cat config.php | grep "datadirectory" | awk -F "'" '{print $4}')
|
||||
OWNCLOUD_DBTYPE=$(cat config.php | grep "dbtype" | awk -F "'" '{print $4}')
|
||||
OWNCLOUD_DBNAME=$(cat config.php | grep "dbname" | awk -F "'" '{print $4}')
|
||||
OWNCLOUD_DBHOST=$(cat config.php | grep "dbhost" | awk -F "'" '{print $4}')
|
||||
OWNCLOUD_DBUSER=$(cat config.php | grep "dbuser" | awk -F "'" '{print $4}')
|
||||
OWNCLOUD_DBPASS=$(cat config.php | grep "dbpassword" | awk -F "'" '{print $4}')
|
||||
OWNCLOUD_SECRET=$(cat config.php | grep "secret" | awk -F "'" '{print $4}')
|
||||
|
||||
sed -i "s|'instanceid'.*|'instanceid' => '$OWNCLOUD_INSTANCE_ID',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'passwordsalt'.*|'passwordsalt' => '$OWNCLOUD_PASSWORD_SALT',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'datadirectory'.*|'datadirectory' => '$OWNCLOUD_DATA_DIR',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'dbtype'.*|'dbtype' => '$OWNCLOUD_DBTYPE',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'dbname'.*|'dbname' => '$OWNCLOUD_DBNAME',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'dbhost'.*|'dbhost' => '$OWNCLOUD_DBHOST',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'dbuser'.*|'dbuser' => '$OWNCLOUD_DBUSER',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'dbpassword'.*|'dbpassword' => '$OWNCLOUD_DBPASS',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'secret'.*|'secret' => '$OWNCLOUD_SECRET',|g" $OWNCLOUD_PATH/config/config.php
|
||||
fi
|
||||
|
||||
# re-index the files
|
||||
for d in /home/*/ ; do
|
||||
USRNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USRNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ files:scan $USRNAME
|
||||
$OWNCLOUD_PATH/occ files:scan $USRNAME
|
||||
fi
|
||||
done
|
||||
|
||||
# TODO enable this once upgrade is confirmed working
|
||||
#apt-get -y remove --purge owncloud
|
||||
#rm -rf /etc/owncloud
|
||||
#rm -rf /usr/share/owncloud
|
||||
#rm -rf /var/lib/owncloud
|
||||
}
|
||||
|
||||
function install_owncloud_from_repo {
|
||||
function install_owncloud_official_deb {
|
||||
# new version not based on debian package
|
||||
if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
|
||||
return
|
||||
|
@ -6554,20 +6612,12 @@ function install_owncloud_from_repo {
|
|||
fi
|
||||
fi
|
||||
|
||||
OWNCLOUD_PATH=/var/www/$OWNCLOUD_DOMAIN_NAME/htdocs
|
||||
|
||||
# was this previously installed from a package?
|
||||
WAS_INSTALLED_FROM_PACKAGE=
|
||||
if [ -d /etc/owncloud ]; then
|
||||
WAS_INSTALLED_FROM_PACKAGE='yes'
|
||||
fi
|
||||
|
||||
# update to a new commit if needed
|
||||
set_repo_commit $OWNCLOUD_PATH "Owncloud commit" "$OWNCLOUD_COMMIT" $OWNCLOUD_REPO
|
||||
# begin doing an upgrade if needed
|
||||
upgrade_owncloud_start
|
||||
|
||||
OWNCLOUD_COMPLETION_MSG1=$" *** ${PROJECT_NAME} $SYSTEM_TYPE is now installed ***"
|
||||
OWNCLOUD_COMPLETION_MSG2=$"Open $OWNCLOUD_DOMAIN_NAME in a web browser to complete the setup"
|
||||
if grep -Fxq "install_owncloud_from_repo" $COMPLETION_FILE; then
|
||||
if grep -Fxq "install_owncloud_official_deb" $COMPLETION_FILE; then
|
||||
if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" ]]; then
|
||||
install_owncloud_repo_music_app
|
||||
backup_to_friends_servers
|
||||
|
@ -6596,43 +6646,30 @@ function install_owncloud_from_repo {
|
|||
echo $'Removed Apache installation after Owncloud install'
|
||||
fi
|
||||
|
||||
# create the directory where owncloud will live
|
||||
if [ ! -d /var/www/$OWNCLOUD_DOMAIN_NAME ]; then
|
||||
mkdir /var/www/$OWNCLOUD_DOMAIN_NAME
|
||||
fi
|
||||
|
||||
# clone the owncloud repo
|
||||
cd /var/www/$OWNCLOUD_DOMAIN_NAME
|
||||
if [ -d $OWNCLOUD_PATH ]; then
|
||||
if [ $WAS_INSTALLED_FROM_PACKAGE ]; then
|
||||
# remove the existing link to /usr/share/owncloud
|
||||
rm $OWNCLOUD_PATH
|
||||
if [ -d $OWNCLOUD_PATH ]; then
|
||||
echo $'Tried to unlink old owncloud, but link remains'
|
||||
exit 67248
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
git_clone $OWNCLOUD_REPO $OWNCLOUD_PATH
|
||||
cd $OWNCLOUD_PATH
|
||||
git checkout $OWNCLOUD_COMMIT -b $OWNCLOUD_COMMIT
|
||||
|
||||
# record the current commit
|
||||
if ! grep -q "Owncloud commit" $COMPLETION_FILE; then
|
||||
echo "Owncloud commit:$OWNCLOUD_COMMIT" >> $COMPLETION_FILE
|
||||
else
|
||||
sed -i "s/Owncloud commit.*/Owncloud commit:$OWNCLOUD_COMMIT/g" $COMPLETION_FILE
|
||||
# get the official owncloud deb package. Note that this is not the same as the one
|
||||
# from the debian repos, and doesn't follow the debian packaging guidelines
|
||||
cd $INSTALL_DIR
|
||||
wget -nv https://download.owncloud.org/download/repositories/stable/Debian_8.0/Release.key -O owncloud.key
|
||||
apt-key add - < owncloud.key
|
||||
if [ ! -f /etc/apt/sources.list.d/owncloud.list ]; then
|
||||
echo 'deb http://download.owncloud.org/download/repositories/stable/Debian_8.0/ /' >> /etc/apt/sources.list.d/owncloud.list
|
||||
fi
|
||||
apt-get update
|
||||
apt-get -y install owncloud
|
||||
|
||||
install_mariadb
|
||||
get_mariadb_password
|
||||
if [ ! -d $OWNCLOUD_PATH ]; then
|
||||
echo $'Owncloud was not installed'
|
||||
exit 82584
|
||||
fi
|
||||
|
||||
get_mariadb_owncloud_admin_password
|
||||
if [ ! $OWNCLOUD_ADMIN_PASSWORD ]; then
|
||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
OWNCLOUD_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
OWNCLOUD_ADMIN_PASSWORD="$(openssl rand -base64 32)"
|
||||
OWNCLOUD_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -6658,10 +6695,12 @@ function install_owncloud_from_repo {
|
|||
chmod 600 /home/$MY_USERNAME/README
|
||||
fi
|
||||
|
||||
if [ ! $WAS_INSTALLED_FROM_PACKAGE ]; then
|
||||
create_database owncloud "$OWNCLOUD_ADMIN_PASSWORD"
|
||||
if [ -d /etc/owncloud ]; then
|
||||
remove_database owncloud
|
||||
fi
|
||||
|
||||
create_database owncloud "$OWNCLOUD_ADMIN_PASSWORD"
|
||||
|
||||
if [[ $ONION_ONLY == "no" ]]; then
|
||||
nginx_http_redirect $OWNCLOUD_DOMAIN_NAME
|
||||
echo 'server {' >> /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME
|
||||
|
@ -6849,7 +6888,40 @@ function install_owncloud_from_repo {
|
|||
echo "Owncloud domain:$OWNCLOUD_DOMAIN_NAME" >> $COMPLETION_FILE
|
||||
fi
|
||||
|
||||
echo 'install_owncloud_from_repo' >> $COMPLETION_FILE
|
||||
upgrade_owncloud_finish
|
||||
|
||||
# copy the configuration file
|
||||
if [ ! -f $OWNCLOUD_PATH/config/config.php ]; then
|
||||
if [ ! -f $OWNCLOUD_PATH/config/config.sample.php ]; then
|
||||
echo $'No owncloud configuration sample file found'
|
||||
exit 54289
|
||||
fi
|
||||
cp $OWNCLOUD_PATH/config/config.sample.php $OWNCLOUD_PATH/config/config.php
|
||||
fi
|
||||
|
||||
if [ -f $OWNCLOUD_UPGRADE_PATH/config/config.php ]; then
|
||||
OWNCLOUD_INSTANCE_ID="$(openssl rand -base64 14 | cut -c1-12)"
|
||||
OWNCLOUD_PASSWORD_SALT="$(openssl rand -base64 32 | cut -c1-30)"
|
||||
OWNCLOUD_DATA_DIR='/var/www/owncloud/data'
|
||||
OWNCLOUD_DBTYPE='mysql'
|
||||
OWNCLOUD_DBNAME='owncloud'
|
||||
OWNCLOUD_DBHOST='localhost'
|
||||
OWNCLOUD_DBUSER="owncloudadmin"
|
||||
OWNCLOUD_DBPASS="$OWNCLOUD_ADMIN_PASSWORD"
|
||||
OWNCLOUD_SECRET="$(openssl rand -base64 32 | cut -c1-30)$(openssl rand -base64 32 | cut -c1-30)$(openssl rand -base64 32 | cut -c1-30)$(openssl rand -base64 32 | cut -c1-30)"
|
||||
|
||||
sed -i "s|'instanceid'.*|'instanceid' => '$OWNCLOUD_INSTANCE_ID',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'passwordsalt'.*|'passwordsalt' => '$OWNCLOUD_PASSWORD_SALT',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'datadirectory'.*|'datadirectory' => '$OWNCLOUD_DATA_DIR',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'dbtype'.*|'dbtype' => '$OWNCLOUD_DBTYPE',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'dbname'.*|'dbname' => '$OWNCLOUD_DBNAME',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'dbhost'.*|'dbhost' => '$OWNCLOUD_DBHOST',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'dbuser'.*|'dbuser' => '$OWNCLOUD_DBUSER',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'dbpassword'.*|'dbpassword' => '$OWNCLOUD_DBPASS',|g" $OWNCLOUD_PATH/config/config.php
|
||||
sed -i "s|'secret'.*|'secret' => '$OWNCLOUD_SECRET',|g" $OWNCLOUD_PATH/config/config.php
|
||||
fi
|
||||
|
||||
echo 'install_owncloud_official_deb' >> $COMPLETION_FILE
|
||||
|
||||
if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" ]]; then
|
||||
install_owncloud_repo_music_app
|
||||
|
@ -6994,7 +7066,7 @@ function install_gogs {
|
|||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
GIT_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
GIT_ADMIN_PASSWORD="$(openssl rand -base64 32)"
|
||||
GIT_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -7560,7 +7632,7 @@ function install_xmpp {
|
|||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
XMPP_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
XMPP_PASSWORD="$(openssl rand -base64 8)"
|
||||
XMPP_PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
|
||||
fi
|
||||
fi
|
||||
prosodyctl register $MY_USERNAME $DEFAULT_DOMAIN_NAME $XMPP_PASSWORD
|
||||
|
@ -7786,11 +7858,11 @@ function install_irc_server {
|
|||
sed -i 's/;MaxUsers = 23/MaxUsers = 23/g' /etc/ngircd/ngircd.conf
|
||||
sed -i "s|;KeyFile = /etc/ngircd/#chan.key|KeyFile = /etc/ngircd/#${PROJECT_NAME}.key|g" /etc/ngircd/ngircd.conf
|
||||
sed -i "s/;CloakHost = cloaked.host/CloakHost = ${PROJECT_NAME}/g" /etc/ngircd/ngircd.conf
|
||||
IRC_SALT="$(openssl rand -base64 32)"
|
||||
IRC_SALT="$(openssl rand -base64 32 | cut -c1-30)"
|
||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
IRC_OPERATOR_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
IRC_OPERATOR_PASSWORD="$(openssl rand -base64 8)"
|
||||
IRC_OPERATOR_PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
|
||||
fi
|
||||
sed -i "s|;CloakHostSalt = abcdefghijklmnopqrstuvwxyz|CloakHostSalt = $IRC_SALT|g" /etc/ngircd/ngircd.conf
|
||||
sed -i 's/;ConnectIPv4 = yes/ConnectIPv4 = yes/g' /etc/ngircd/ngircd.conf
|
||||
|
@ -7928,7 +8000,7 @@ function install_wiki {
|
|||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
WIKI_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
WIKI_ADMIN_PASSWORD="$(openssl rand -base64 16)"
|
||||
WIKI_ADMIN_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
|
||||
fi
|
||||
fi
|
||||
HASHED_WIKI_PASSWORD=$(echo -n "$WIKI_ADMIN_PASSWORD" | md5sum | awk -F ' ' '{print $1}')
|
||||
|
@ -8523,7 +8595,7 @@ function install_blog {
|
|||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
FULLBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
FULLBLOG_ADMIN_PASSWORD="$(openssl rand -base64 16)"
|
||||
FULLBLOG_ADMIN_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
|
||||
fi
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
|
@ -8606,7 +8678,7 @@ function install_rss_reader {
|
|||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
RSS_READER_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
RSS_READER_ADMIN_PASSWORD="$(openssl rand -base64 32)"
|
||||
RSS_READER_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -8883,7 +8955,7 @@ function install_gnu_social {
|
|||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
MICROBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
MICROBLOG_ADMIN_PASSWORD="$(openssl rand -base64 32)"
|
||||
MICROBLOG_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -9430,7 +9502,7 @@ function install_search_engine {
|
|||
|
||||
# replace the secret key
|
||||
if ! grep "Search engine key" $COMPLETION_FILE; then
|
||||
SEARCH_ENGINE_SECRET_KEY="$(openssl rand -base64 32)"
|
||||
SEARCH_ENGINE_SECRET_KEY="$(openssl rand -base64 32 | cut -c1-30)"
|
||||
echo "Search engine key:${SEARCH_ENGINE_SECRET_KEY}" >> $COMPLETION_FILE
|
||||
else
|
||||
SEARCH_ENGINE_SECRET_KEY=$(cat $COMPLETION_FILE | grep "Search engine key" | awk -F ':' '{print $2}')
|
||||
|
@ -9467,7 +9539,7 @@ function install_search_engine {
|
|||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
SEARCH_ENGINE_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
SEARCH_ENGINE_PASSWORD="$(openssl rand -base64 16)"
|
||||
SEARCH_ENGINE_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
|
||||
fi
|
||||
fi
|
||||
echo "$SEARCH_ENGINE_PASSWORD" | htpasswd -i -s -c /etc/nginx/.htpasswd $MY_USERNAME
|
||||
|
@ -9563,7 +9635,7 @@ function install_hubzilla {
|
|||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
HUBZILLA_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
HUBZILLA_ADMIN_PASSWORD="$(openssl rand -base64 32)"
|
||||
HUBZILLA_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
|
||||
fi
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
|
@ -9795,7 +9867,7 @@ function install_hubzilla {
|
|||
echo "\$a->config['system']['baseurl'] = 'http://${HUBZILLA_ONION_HOSTNAME}';" >> $HUBZILLA_PATH/.htconfig.php
|
||||
fi
|
||||
echo "\$a->config['system']['sitename'] = \"Hubzilla\";" >> $HUBZILLA_PATH/.htconfig.php
|
||||
HUBZILLA_LOCATION_HASH="$(openssl rand -base64 32)"
|
||||
HUBZILLA_LOCATION_HASH="$(openssl rand -base64 32 | cut -c1-30)"
|
||||
echo "\$a->config['system']['location_hash'] = '${HUBZILLA_LOCATION_HASH}';" >> $HUBZILLA_PATH/.htconfig.php
|
||||
echo "\$a->config['system']['register_policy'] = REGISTER_OPEN;" >> $HUBZILLA_PATH/.htconfig.php
|
||||
echo "\$a->config['system']['register_text'] = '';" >> $HUBZILLA_PATH/.htconfig.php
|
||||
|
@ -10520,9 +10592,9 @@ function install_voip {
|
|||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
VOIP_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
VOIP_SERVER_PASSWORD="$(openssl rand -base64 16)"
|
||||
VOIP_SERVER_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
|
||||
if [ ${#VOIP_SERVER_PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then
|
||||
VOIP_SERVER_PASSWORD="$(openssl rand -base64 16)"
|
||||
VOIP_SERVER_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -10617,7 +10689,7 @@ function install_sip {
|
|||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
SIP_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
SIP_SERVER_PASSWORD="$(openssl rand -base64 10)"
|
||||
SIP_SERVER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -10827,8 +10899,7 @@ script_for_attaching_usb_drive
|
|||
install_web_server
|
||||
install_web_server_access_control
|
||||
configure_firewall_for_web_server
|
||||
install_owncloud_from_repo
|
||||
upgrade_owncloud
|
||||
install_owncloud_official_deb
|
||||
install_owncloud_repo_music_app
|
||||
configure_owncloud_onion_site
|
||||
upgrade_golang
|
||||
|
|
|
@ -279,7 +279,7 @@ fi
|
|||
if grep -q "install_owncloud_repo" $COMPLETION_FILE; then
|
||||
export OC_PASS="$NEW_USER_PASSWORD"
|
||||
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
|
||||
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ user:add --password-from-env --display-name="$MY_USERNAME" --group="users" $MY_USERNAME
|
||||
/var/www/owncloud/occ user:add --password-from-env --display-name="$MY_USERNAME" --group="users" $MY_USERNAME
|
||||
if [ ! "$?" = "0" ]; then
|
||||
echo 'Owncloud user could not be added'
|
||||
if grep -q "install_xmpp" $COMPLETION_FILE; then
|
||||
|
|
|
@ -370,9 +370,9 @@ function backup_directories {
|
|||
"none, none, /var/lib/tox-bootstrapd, tox"
|
||||
"/var/www/${MICROBLOG_DOMAIN_NAME}, gnusocial, /root/tempgnusocialdata, gnusocialdata"
|
||||
"none, none, /var/www/${MICROBLOG_DOMAIN_NAME}/htdocs, gnusocial"
|
||||
"/var/www/${OWNCLOUD_DOMAIN_NAME}, owncloud, /root/tempowncloudrepodata, owncloudrepodata"
|
||||
"none, none, /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data, owncloudrepofiles"
|
||||
"none, none, /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config, owncloudrepoconfig"
|
||||
"/var/www/owncloud, owncloud, /root/tempownclouddata, ownclouddata"
|
||||
"none, none, /var/www/owncloud/data, owncloudfiles"
|
||||
"none, none, /var/www/owncloud/config, owncloudconfig"
|
||||
"/var/www/${HUBZILLA_DOMAIN_NAME}, hubzilla, /root/temphubzilladata, hubzilladata"
|
||||
"none, none, /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs, hubzilla"
|
||||
"none, none, /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs, blog"
|
||||
|
@ -530,9 +530,9 @@ function valid_backup_destination {
|
|||
"$destination_dir" == "ssl" || \
|
||||
"$destination_dir" == "ttrss" || \
|
||||
"$destination_dir" == "blog" || \
|
||||
"$destination_dir" == "owncloudrepofiles" || \
|
||||
"$destination_dir" == "owncloudrepoconfig" || \
|
||||
"$destination_dir" == "owncloudrepodata" || \
|
||||
"$destination_dir" == "owncloudfiles" || \
|
||||
"$destination_dir" == "owncloudconfig" || \
|
||||
"$destination_dir" == "ownclouddata" || \
|
||||
"$destination_dir" == "mailinglist" ]]; then
|
||||
is_valid="no"
|
||||
fi
|
||||
|
|
|
@ -330,332 +330,332 @@ function backup_owncloud {
|
|||
if [ -d /etc/owncloud ]; then
|
||||
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
|
||||
suspend_site ${OWNCLOUD_DOMAIN_NAME}
|
||||
backup_database_to_friend owncloudrepo
|
||||
backup_directory_to_friend /root/tempowncloudrepodata owncloudrepodata
|
||||
backup_database_to_friend owncloud
|
||||
backup_directory_to_friend /root/tempownclouddata ownclouddata
|
||||
echo $"Backing up Owncloud data"
|
||||
if [ -d /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data ]; then
|
||||
backup_directory_to_friend /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data owncloudrepofiles
|
||||
fi
|
||||
backup_directory_to_friend /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config owncloudrepoconfig
|
||||
restart_site
|
||||
fi
|
||||
if [ -d /var/www/owncloud/data ]; then
|
||||
backup_directory_to_friend /var/www/owncloud/data owncloudfiles
|
||||
fi
|
||||
backup_directory_to_friend /var/www/owncloud/config owncloudconfig
|
||||
restart_site
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_gogs {
|
||||
if [ -d /home/git/go/src/github.com/gogits ]; then
|
||||
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
|
||||
suspend_site ${GIT_DOMAIN_NAME}
|
||||
backup_database_to_friend gogs
|
||||
backup_directory_to_friend /root/tempgogsdata gogsdata
|
||||
echo $"Obtaining Gogs settings backup"
|
||||
backup_directory_to_friend /home/git/go/src/github.com/gogits/gogs/custom gogs
|
||||
echo $"Obtaining Gogs repos backup"
|
||||
mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/bob
|
||||
backup_directory_to_friend /home/git/gogs-repositories gogsrepos
|
||||
echo $"Obtaining Gogs authorized_keys backup"
|
||||
backup_directory_to_friend /home/git/.ssh gogsssh
|
||||
restart_site
|
||||
fi
|
||||
if [ -d /home/git/go/src/github.com/gogits ]; then
|
||||
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
|
||||
suspend_site ${GIT_DOMAIN_NAME}
|
||||
backup_database_to_friend gogs
|
||||
backup_directory_to_friend /root/tempgogsdata gogsdata
|
||||
echo $"Obtaining Gogs settings backup"
|
||||
backup_directory_to_friend /home/git/go/src/github.com/gogits/gogs/custom gogs
|
||||
echo $"Obtaining Gogs repos backup"
|
||||
mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/bob
|
||||
backup_directory_to_friend /home/git/gogs-repositories gogsrepos
|
||||
echo $"Obtaining Gogs authorized_keys backup"
|
||||
backup_directory_to_friend /home/git/.ssh gogsssh
|
||||
restart_site
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_wiki {
|
||||
if [ -d /etc/dokuwiki ]; then
|
||||
echo $"Backing up wiki"
|
||||
backup_directory_to_friend /var/lib/dokuwiki wiki
|
||||
backup_directory_to_friend /etc/dokuwiki wiki2
|
||||
fi
|
||||
if [ -d /etc/dokuwiki ]; then
|
||||
echo $"Backing up wiki"
|
||||
backup_directory_to_friend /var/lib/dokuwiki wiki
|
||||
backup_directory_to_friend /etc/dokuwiki wiki2
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_blog {
|
||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME} ]; then
|
||||
echo $"Backing up blog"
|
||||
backup_directory_to_friend /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs blog
|
||||
else
|
||||
echo $"Blog domain specified but not found in /var/www/${FULLBLOG_DOMAIN_NAME}"
|
||||
exit 2578
|
||||
fi
|
||||
fi
|
||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME} ]; then
|
||||
echo $"Backing up blog"
|
||||
backup_directory_to_friend /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs blog
|
||||
else
|
||||
echo $"Blog domain specified but not found in /var/www/${FULLBLOG_DOMAIN_NAME}"
|
||||
exit 2578
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_certs {
|
||||
if [ -d /etc/ssl ]; then
|
||||
echo $"Backing up certificates"
|
||||
backup_directory_to_friend /etc/ssl ssl
|
||||
fi
|
||||
if [ -d /etc/ssl ]; then
|
||||
echo $"Backing up certificates"
|
||||
backup_directory_to_friend /etc/ssl ssl
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_mailing_list {
|
||||
if [ -d /var/spool/mlmmj ]; then
|
||||
echo $"Backing up the public mailing list"
|
||||
backup_directory_to_friend /var/spool/mlmmj mailinglist
|
||||
fi
|
||||
if [ -d /var/spool/mlmmj ]; then
|
||||
echo $"Backing up the public mailing list"
|
||||
backup_directory_to_friend /var/spool/mlmmj mailinglist
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_xmpp {
|
||||
if [ -d /var/lib/prosody ]; then
|
||||
echo $"Backing up the XMPP settings"
|
||||
backup_directory_to_friend /var/lib/prosody xmpp
|
||||
fi
|
||||
if [ -d /var/lib/prosody ]; then
|
||||
echo $"Backing up the XMPP settings"
|
||||
backup_directory_to_friend /var/lib/prosody xmpp
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_web_server {
|
||||
if [ -d /etc/nginx ]; then
|
||||
echo $"Backing up web settings"
|
||||
backup_directory_to_friend /etc/nginx/sites-available web
|
||||
fi
|
||||
if [ -d /etc/nginx ]; then
|
||||
echo $"Backing up web settings"
|
||||
backup_directory_to_friend /etc/nginx/sites-available web
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_admin_readme {
|
||||
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
||||
echo $"Backing up README"
|
||||
if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$ADMIN_USERNAME/tempbackup
|
||||
fi
|
||||
cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup
|
||||
backup_directory_to_friend /home/$ADMIN_USERNAME/tempbackup readme
|
||||
fi
|
||||
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
||||
echo $"Backing up README"
|
||||
if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$ADMIN_USERNAME/tempbackup
|
||||
fi
|
||||
cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup
|
||||
backup_directory_to_friend /home/$ADMIN_USERNAME/tempbackup readme
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_ipfs {
|
||||
if [ -d /home/$ADMIN_USERNAME/.ipfs ]; then
|
||||
echo $"Backing up IPFS"
|
||||
backup_directory_to_friend /home/$ADMIN_USERNAME/.ipfs ipfs
|
||||
fi
|
||||
if [ -d /home/$ADMIN_USERNAME/.ipfs ]; then
|
||||
echo $"Backing up IPFS"
|
||||
backup_directory_to_friend /home/$ADMIN_USERNAME/.ipfs ipfs
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_dlna {
|
||||
if [ -d /var/cache/minidlna ]; then
|
||||
echo $"Backing up DLNA cache"
|
||||
backup_directory_to_friend /var/cache/minidlna dlna
|
||||
fi
|
||||
if [ -d /var/cache/minidlna ]; then
|
||||
echo $"Backing up DLNA cache"
|
||||
backup_directory_to_friend /var/cache/minidlna dlna
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_voip {
|
||||
if [ -f /etc/mumble-server.ini ]; then
|
||||
echo $"Backing up VoIP settings"
|
||||
if [ ! -d /root/tempvoipbackup ]; then
|
||||
mkdir -p /root/tempvoipbackup
|
||||
fi
|
||||
cp -f /etc/mumble-server.ini /root/tempvoipbackup
|
||||
cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup
|
||||
cp -f /etc/sipwitch.conf /root/tempvoipbackup
|
||||
backup_directory_to_friend /root/tempvoipbackup voip
|
||||
fi
|
||||
if [ -f /etc/mumble-server.ini ]; then
|
||||
echo $"Backing up VoIP settings"
|
||||
if [ ! -d /root/tempvoipbackup ]; then
|
||||
mkdir -p /root/tempvoipbackup
|
||||
fi
|
||||
cp -f /etc/mumble-server.ini /root/tempvoipbackup
|
||||
cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup
|
||||
cp -f /etc/sipwitch.conf /root/tempvoipbackup
|
||||
backup_directory_to_friend /root/tempvoipbackup voip
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_tox {
|
||||
if [ -d /var/lib/tox-bootstrapd ]; then
|
||||
echo "Backing up Tox node settings"
|
||||
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
|
||||
rm -rf /var/lib/tox-bootstrapd/Maildir
|
||||
fi
|
||||
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
|
||||
backup_directory_to_friend /var/lib/tox-bootstrapd tox
|
||||
fi
|
||||
if [ -d /var/lib/tox-bootstrapd ]; then
|
||||
echo "Backing up Tox node settings"
|
||||
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
|
||||
rm -rf /var/lib/tox-bootstrapd/Maildir
|
||||
fi
|
||||
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
|
||||
backup_directory_to_friend /var/lib/tox-bootstrapd tox
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_mariadb {
|
||||
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
|
||||
if [ ! -d /root/tempmariadb ]; then
|
||||
mkdir /root/tempmariadb
|
||||
fi
|
||||
mysqldump --password=$DATABASE_PASSWORD mysql user > /root/tempmariadb/mysql.sql
|
||||
if [ ! -s /root/tempmariadb/mysql.sql ]; then
|
||||
echo $"Unable to backup MariaDB settings"
|
||||
rm -rf /root/tempmariadb
|
||||
# Send a warning email
|
||||
echo $"Unable to export database settings" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS
|
||||
exit 653
|
||||
fi
|
||||
echo "$DATABASE_PASSWORD" > /root/tempmariadb/db
|
||||
chmod 400 /root/tempmariadb/db
|
||||
backup_directory_to_friend /root/tempmariadb mariadb
|
||||
fi
|
||||
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
|
||||
if [ ! -d /root/tempmariadb ]; then
|
||||
mkdir /root/tempmariadb
|
||||
fi
|
||||
mysqldump --password=$DATABASE_PASSWORD mysql user > /root/tempmariadb/mysql.sql
|
||||
if [ ! -s /root/tempmariadb/mysql.sql ]; then
|
||||
echo $"Unable to backup MariaDB settings"
|
||||
rm -rf /root/tempmariadb
|
||||
# Send a warning email
|
||||
echo $"Unable to export database settings" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS
|
||||
exit 653
|
||||
fi
|
||||
echo "$DATABASE_PASSWORD" > /root/tempmariadb/db
|
||||
chmod 400 /root/tempmariadb/db
|
||||
backup_directory_to_friend /root/tempmariadb mariadb
|
||||
fi
|
||||
}
|
||||
|
||||
# Returns the filename of a key share
|
||||
function get_key_share {
|
||||
no_of_shares=$1
|
||||
USERNAME="$2"
|
||||
REMOTE_DOMAIN="$3"
|
||||
no_of_shares=$1
|
||||
USERNAME="$2"
|
||||
REMOTE_DOMAIN="$3"
|
||||
|
||||
# Get a share index based on the supplied domain name
|
||||
# This ensures that the same share is always given to the same domain
|
||||
sharenumstr=$(md5sum <<< "$REMOTE_DOMAIN")
|
||||
share_index=$(echo $((0x${sharenumstr%% *} % ${no_of_shares})) | tr -d -)
|
||||
# Get a share index based on the supplied domain name
|
||||
# This ensures that the same share is always given to the same domain
|
||||
sharenumstr=$(md5sum <<< "$REMOTE_DOMAIN")
|
||||
share_index=$(echo $((0x${sharenumstr%% *} % ${no_of_shares})) | tr -d -)
|
||||
|
||||
# get the filename
|
||||
share_files=(/home/$USERNAME/.gnupg_fragments/keyshare.asc.*)
|
||||
share_filename=${share_files[share_index]}
|
||||
# get the filename
|
||||
share_files=(/home/$USERNAME/.gnupg_fragments/keyshare.asc.*)
|
||||
share_filename=${share_files[share_index]}
|
||||
|
||||
echo "$share_filename"
|
||||
echo "$share_filename"
|
||||
}
|
||||
|
||||
function disperse_key_shares {
|
||||
USERNAME=$1
|
||||
REMOTE_DOMAIN=$2
|
||||
REMOTE_SSH_PORT=$3
|
||||
REMOTE_PASSWORD=$4
|
||||
REMOTE_SERVER=$5
|
||||
USERNAME=$1
|
||||
REMOTE_DOMAIN=$2
|
||||
REMOTE_SSH_PORT=$3
|
||||
REMOTE_PASSWORD=$4
|
||||
REMOTE_SERVER=$5
|
||||
|
||||
if [ -d /home/$USERNAME/.gnupg_fragments ]; then
|
||||
if [ $REMOTE_DOMAIN ]; then
|
||||
cd /home/$USERNAME/.gnupg_fragments
|
||||
no_of_shares=$(ls -afq keyshare.asc.* | wc -l)
|
||||
if (( no_of_shares > 1 )); then
|
||||
share_filename=$(get_key_share $no_of_shares "$USERNAME" "$REMOTE_DOMAIN")
|
||||
if [ -d /home/$USERNAME/.gnupg_fragments ]; then
|
||||
if [ $REMOTE_DOMAIN ]; then
|
||||
cd /home/$USERNAME/.gnupg_fragments
|
||||
no_of_shares=$(ls -afq keyshare.asc.* | wc -l)
|
||||
if (( no_of_shares > 1 )); then
|
||||
share_filename=$(get_key_share $no_of_shares "$USERNAME" "$REMOTE_DOMAIN")
|
||||
|
||||
# create a temp directory containing the share
|
||||
temp_key_share_dir=/home/$USERNAME/tempkey
|
||||
temp_key_share_fragments=$temp_key_share_dir/.gnupg_fragments_${USERNAME}
|
||||
mkdir -p $temp_key_share_fragments
|
||||
cp $share_filename $temp_key_share_fragments/
|
||||
# create a temp directory containing the share
|
||||
temp_key_share_dir=/home/$USERNAME/tempkey
|
||||
temp_key_share_fragments=$temp_key_share_dir/.gnupg_fragments_${USERNAME}
|
||||
mkdir -p $temp_key_share_fragments
|
||||
cp $share_filename $temp_key_share_fragments/
|
||||
|
||||
# copy the fragments directory to the remote server
|
||||
/usr/bin/sshpass -p "$REMOTE_PASSWORD" \
|
||||
scp -r -P $REMOTE_SSH_PORT $temp_key_share_fragments $REMOTE_SERVER
|
||||
if [ ! "$?" = "0" ]; then
|
||||
# Send a warning email
|
||||
echo "Key share to $REMOTE_SERVER failed" | \
|
||||
mail -s "${PROJECT_NAME} social key management" $MY_EMAIL_ADDRESS
|
||||
else
|
||||
# Send a confirmation email
|
||||
echo "Key ${share_filename} shared to $REMOTE_SERVER" | \
|
||||
mail -s "${PROJECT_NAME} social key management" $MY_EMAIL_ADDRESS
|
||||
fi
|
||||
# copy the fragments directory to the remote server
|
||||
/usr/bin/sshpass -p "$REMOTE_PASSWORD" \
|
||||
scp -r -P $REMOTE_SSH_PORT $temp_key_share_fragments $REMOTE_SERVER
|
||||
if [ ! "$?" = "0" ]; then
|
||||
# Send a warning email
|
||||
echo "Key share to $REMOTE_SERVER failed" | \
|
||||
mail -s "${PROJECT_NAME} social key management" $MY_EMAIL_ADDRESS
|
||||
else
|
||||
# Send a confirmation email
|
||||
echo "Key ${share_filename} shared to $REMOTE_SERVER" | \
|
||||
mail -s "${PROJECT_NAME} social key management" $MY_EMAIL_ADDRESS
|
||||
fi
|
||||
|
||||
# remove the temp file/directory
|
||||
shred -zu $temp_key_share_fragments/*
|
||||
rm -rf $temp_key_share_dir
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# remove the temp file/directory
|
||||
shred -zu $temp_key_share_fragments/*
|
||||
rm -rf $temp_key_share_dir
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function valid_backup_destination {
|
||||
destination_dir="$1"
|
||||
is_valid="yes"
|
||||
destination_dir="$1"
|
||||
is_valid="yes"
|
||||
|
||||
if [[ "$destination_dir" == "hubzilla" || \
|
||||
"$destination_dir" == "hubzilladata" || \
|
||||
"$destination_dir" == "gogs" || \
|
||||
"$destination_dir" == "gogsrepos" || \
|
||||
"$destination_dir" == "gogsssh" || \
|
||||
"$destination_dir" == "gnusocial" || \
|
||||
"$destination_dir" == "gnusocialdata" || \
|
||||
"$destination_dir" == "mariadb" || \
|
||||
"$destination_dir" == "config" || \
|
||||
"$destination_dir" == "letsencrypt" || \
|
||||
"$destination_dir" == "wiki" || \
|
||||
"$destination_dir" == "wiki2" || \
|
||||
"$destination_dir" == "xmpp" || \
|
||||
"$destination_dir" == "ipfs" || \
|
||||
"$destination_dir" == "dlna" || \
|
||||
"$destination_dir" == "tox" || \
|
||||
"$destination_dir" == "ssl" || \
|
||||
"$destination_dir" == "blog" || \
|
||||
"$destination_dir" == "owncloudrepofiles" || \
|
||||
"$destination_dir" == "owncloudrepoconfig" || \
|
||||
"$destination_dir" == "owncloudrepodata" || \
|
||||
"$destination_dir" == "mailinglist" ]]; then
|
||||
is_valid="no"
|
||||
fi
|
||||
if [[ "$destination_dir" == "hubzilla" || \
|
||||
"$destination_dir" == "hubzilladata" || \
|
||||
"$destination_dir" == "gogs" || \
|
||||
"$destination_dir" == "gogsrepos" || \
|
||||
"$destination_dir" == "gogsssh" || \
|
||||
"$destination_dir" == "gnusocial" || \
|
||||
"$destination_dir" == "gnusocialdata" || \
|
||||
"$destination_dir" == "mariadb" || \
|
||||
"$destination_dir" == "config" || \
|
||||
"$destination_dir" == "letsencrypt" || \
|
||||
"$destination_dir" == "wiki" || \
|
||||
"$destination_dir" == "wiki2" || \
|
||||
"$destination_dir" == "xmpp" || \
|
||||
"$destination_dir" == "ipfs" || \
|
||||
"$destination_dir" == "dlna" || \
|
||||
"$destination_dir" == "tox" || \
|
||||
"$destination_dir" == "ssl" || \
|
||||
"$destination_dir" == "blog" || \
|
||||
"$destination_dir" == "owncloudfiles" || \
|
||||
"$destination_dir" == "owncloudconfig" || \
|
||||
"$destination_dir" == "ownclouddata" || \
|
||||
"$destination_dir" == "mailinglist" ]]; then
|
||||
is_valid="no"
|
||||
fi
|
||||
|
||||
echo $is_valid
|
||||
echo $is_valid
|
||||
}
|
||||
|
||||
function backup_extra_directories {
|
||||
if [ ! -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
||||
return
|
||||
fi
|
||||
if [ ! -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
echo $"Backing up some additional directories"
|
||||
while read backup_line
|
||||
do
|
||||
backup_dir=$(echo "$backup_line" | awk -F ',' '{print $1}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
if [ -d "$backup_dir" ]; then
|
||||
destination_dir=$(echo "$backup_line" | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
if [[ $(valid_backup_destination "$destination_dir") == "yes" ]]; then
|
||||
backup_directory_to_friend "$backup_dir" "$destination_dir"
|
||||
else
|
||||
echo $"WARNING: The backup directory $destination_dir is already used."
|
||||
echo $"Choose a different destination name for backing up $backup_dir"
|
||||
fi
|
||||
else
|
||||
echo $"WARNING: Directory $backup_dir does not exist"
|
||||
fi
|
||||
done <$BACKUP_EXTRA_DIRECTORIES
|
||||
echo $"Backing up some additional directories"
|
||||
while read backup_line
|
||||
do
|
||||
backup_dir=$(echo "$backup_line" | awk -F ',' '{print $1}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
if [ -d "$backup_dir" ]; then
|
||||
destination_dir=$(echo "$backup_line" | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
if [[ $(valid_backup_destination "$destination_dir") == "yes" ]]; then
|
||||
backup_directory_to_friend "$backup_dir" "$destination_dir"
|
||||
else
|
||||
echo $"WARNING: The backup directory $destination_dir is already used."
|
||||
echo $"Choose a different destination name for backing up $backup_dir"
|
||||
fi
|
||||
else
|
||||
echo $"WARNING: Directory $backup_dir does not exist"
|
||||
fi
|
||||
done <$BACKUP_EXTRA_DIRECTORIES
|
||||
}
|
||||
|
||||
TEST_MODE="no"
|
||||
if [[ "$1" == "test" ]]; then
|
||||
TEST_MODE="yes"
|
||||
TEST_MODE="yes"
|
||||
fi
|
||||
|
||||
backup_configuration
|
||||
if [[ $TEST_MODE == "no" ]]; then
|
||||
backup_users
|
||||
backup_letsencrypt
|
||||
backup_tor
|
||||
backup_gnusocial
|
||||
backup_rss_reader
|
||||
backup_hubzilla
|
||||
backup_owncloud
|
||||
backup_gogs
|
||||
backup_wiki
|
||||
backup_blog
|
||||
backup_certs
|
||||
backup_mailing_list
|
||||
backup_xmpp
|
||||
backup_web_server
|
||||
backup_admin_readme
|
||||
backup_ipfs
|
||||
backup_dlna
|
||||
backup_voip
|
||||
backup_tox
|
||||
backup_mariadb
|
||||
backup_extra_directories
|
||||
backup_users
|
||||
backup_letsencrypt
|
||||
backup_tor
|
||||
backup_gnusocial
|
||||
backup_rss_reader
|
||||
backup_hubzilla
|
||||
backup_owncloud
|
||||
backup_gogs
|
||||
backup_wiki
|
||||
backup_blog
|
||||
backup_certs
|
||||
backup_mailing_list
|
||||
backup_xmpp
|
||||
backup_web_server
|
||||
backup_admin_readme
|
||||
backup_ipfs
|
||||
backup_dlna
|
||||
backup_voip
|
||||
backup_tox
|
||||
backup_mariadb
|
||||
backup_extra_directories
|
||||
fi
|
||||
|
||||
# For each remote server
|
||||
while read remote_server
|
||||
do
|
||||
# Get the server and its password
|
||||
# Format is:
|
||||
# username@domain <port number> /home/username <ssh password>
|
||||
REMOTE_SERVER=$(echo "${remote_server}" | awk -F ' ' '{print $1}')
|
||||
if [ $REMOTE_SERVER ]; then
|
||||
REMOTE_DOMAIN=$(echo "${remote_server}" | awk -F ' ' '{print $1}' | awk -F '@' '{print $2}')
|
||||
REMOTE_SSH_PORT=$(echo "${remote_server}" | awk -F ' ' '{print $2}')
|
||||
REMOTE_DIRECTORY=$(echo "${remote_server}" | awk -F ' ' '{print $3}')
|
||||
REMOTE_PASSWORD=$(echo "${remote_server}" | awk -F ' ' '{print $4}')
|
||||
NOW=$(date +"%Y-%m-%d %H:%M:%S")
|
||||
REMOTE_SERVER=$REMOTE_SERVER:$REMOTE_DIRECTORY
|
||||
# Get the server and its password
|
||||
# Format is:
|
||||
# username@domain <port number> /home/username <ssh password>
|
||||
REMOTE_SERVER=$(echo "${remote_server}" | awk -F ' ' '{print $1}')
|
||||
if [ $REMOTE_SERVER ]; then
|
||||
REMOTE_DOMAIN=$(echo "${remote_server}" | awk -F ' ' '{print $1}' | awk -F '@' '{print $2}')
|
||||
REMOTE_SSH_PORT=$(echo "${remote_server}" | awk -F ' ' '{print $2}')
|
||||
REMOTE_DIRECTORY=$(echo "${remote_server}" | awk -F ' ' '{print $3}')
|
||||
REMOTE_PASSWORD=$(echo "${remote_server}" | awk -F ' ' '{print $4}')
|
||||
NOW=$(date +"%Y-%m-%d %H:%M:%S")
|
||||
REMOTE_SERVER=$REMOTE_SERVER:$REMOTE_DIRECTORY
|
||||
|
||||
echo "$NOW Starting backup to $REMOTE_SERVER" >> /var/log/remotebackups.log
|
||||
echo "$NOW Starting backup to $REMOTE_SERVER" >> /var/log/remotebackups.log
|
||||
|
||||
# Social key management
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" ]]; then
|
||||
disperse_key_shares $USERNAME $REMOTE_DOMAIN $REMOTE_SSH_PORT "$REMOTE_PASSWORD" $REMOTE_SERVER
|
||||
fi
|
||||
done
|
||||
# Social key management
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" ]]; then
|
||||
disperse_key_shares $USERNAME $REMOTE_DOMAIN $REMOTE_SSH_PORT "$REMOTE_PASSWORD" $REMOTE_SERVER
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $TEST_MODE == "yes" ]]; then
|
||||
echo "rsync -ratlzv --rsh=\"/usr/bin/sshpass -p '$REMOTE_PASSWORD' ssh -p $REMOTE_SSH_PORT -o StrictHostKeyChecking=no\" $SERVER_DIRECTORY/backup $REMOTE_SERVER"
|
||||
fi
|
||||
rsync -ratlzv --rsh="/usr/bin/sshpass -p \"$REMOTE_PASSWORD\" ssh -p $REMOTE_SSH_PORT -o StrictHostKeyChecking=no" $SERVER_DIRECTORY/backup $REMOTE_SERVER
|
||||
if [ ! "$?" = "0" ]; then
|
||||
echo "$NOW Backup to $REMOTE_SERVER failed" >> /var/log/remotebackups.log
|
||||
# Send a warning email
|
||||
echo "Backup to $REMOTE_SERVER failed" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS
|
||||
else
|
||||
echo "$NOW Backed up to $REMOTE_SERVER" >> /var/log/remotebackups.log
|
||||
fi
|
||||
fi
|
||||
if [[ $TEST_MODE == "yes" ]]; then
|
||||
echo "rsync -ratlzv --rsh=\"/usr/bin/sshpass -p '$REMOTE_PASSWORD' ssh -p $REMOTE_SSH_PORT -o StrictHostKeyChecking=no\" $SERVER_DIRECTORY/backup $REMOTE_SERVER"
|
||||
fi
|
||||
rsync -ratlzv --rsh="/usr/bin/sshpass -p \"$REMOTE_PASSWORD\" ssh -p $REMOTE_SSH_PORT -o StrictHostKeyChecking=no" $SERVER_DIRECTORY/backup $REMOTE_SERVER
|
||||
if [ ! "$?" = "0" ]; then
|
||||
echo "$NOW Backup to $REMOTE_SERVER failed" >> /var/log/remotebackups.log
|
||||
# Send a warning email
|
||||
echo "Backup to $REMOTE_SERVER failed" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS
|
||||
else
|
||||
echo "$NOW Backed up to $REMOTE_SERVER" >> /var/log/remotebackups.log
|
||||
fi
|
||||
fi
|
||||
|
||||
done < /home/${ADMIN_USERNAME}/backup.list
|
||||
|
||||
|
|
|
@ -826,292 +826,292 @@ function restore_owncloud {
|
|||
fi
|
||||
fi
|
||||
if [ $OWNCLOUD_DOMAIN_NAME ]; then
|
||||
restore_database owncloudrepo $OWNCLOUD_DOMAIN_NAME
|
||||
restore_database owncloud $OWNCLOUD_DOMAIN_NAME
|
||||
|
||||
if [ -d $USB_MOUNT/backup/owncloudrepofiles ]; then
|
||||
restore_directory_from_usb /root/tempowncloudrepofiles owncloudrepofiles
|
||||
cp -r /root/tempowncloudrepofiles/* /
|
||||
if [ -d $USB_MOUNT/backup/owncloudfiles ]; then
|
||||
restore_directory_from_usb /root/tempowncloudfiles owncloudfiles
|
||||
cp -r /root/tempowncloudfiles/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 982
|
||||
fi
|
||||
rm -rf /root/tempowncloudrepofiles
|
||||
rm -rf /root/tempowncloudfiles
|
||||
fi
|
||||
|
||||
if [ -d $USB_MOUNT/backup/owncloudrepoconfig ]; then
|
||||
restore_directory_from_usb /root/tempowncloudrepoconfig owncloudrepoconfig
|
||||
cp -r /root/tempowncloudrepoconfig/* /
|
||||
if [ -d $USB_MOUNT/backup/owncloudconfig ]; then
|
||||
restore_directory_from_usb /root/tempowncloudconfig owncloudconfig
|
||||
cp -r /root/tempowncloudconfig/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 7825
|
||||
fi
|
||||
rm -rf /root/tempowncloudrepoconfig
|
||||
rm -rf /root/tempowncloudconfig
|
||||
fi
|
||||
|
||||
# re-index the files
|
||||
chown -R www-data:www-data /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ files:scan $USERNAME
|
||||
fi
|
||||
done
|
||||
fi
|
||||
chown -R www-data:www-data /var/www/owncloud
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
/var/www/owncloud/occ files:scan $USERNAME
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_gogs {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'gogs' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ $GIT_DOMAIN_NAME ]; then
|
||||
restore_database gogs ${GIT_DOMAIN_NAME}
|
||||
if [ -d $USB_MOUNT/backup/gogs ]; then
|
||||
echo $"Restoring Gogs settings"
|
||||
if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then
|
||||
mkdir -p /home/git/go/src/github.com/gogits/gogs/custom
|
||||
fi
|
||||
cp -r /root/tempgogs/home/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 981
|
||||
fi
|
||||
echo $"Restoring Gogs repos"
|
||||
restore_directory_from_usb /root/tempgogsrepos gogsrepos
|
||||
cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 67574
|
||||
fi
|
||||
echo $"Restoring Gogs authorized_keys"
|
||||
restore_directory_from_usb /root/tempgogsssh gogsssh
|
||||
if [ ! -d /home/git/.ssh ]; then
|
||||
mkdir /home/git/.ssh
|
||||
fi
|
||||
cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 8463
|
||||
fi
|
||||
rm -rf /root/tempgogs
|
||||
rm -rf /root/tempgogsrepos
|
||||
rm -rf /root/tempgogsssh
|
||||
chown -R git:git /home/git
|
||||
fi
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'gogs' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ $GIT_DOMAIN_NAME ]; then
|
||||
restore_database gogs ${GIT_DOMAIN_NAME}
|
||||
if [ -d $USB_MOUNT/backup/gogs ]; then
|
||||
echo $"Restoring Gogs settings"
|
||||
if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then
|
||||
mkdir -p /home/git/go/src/github.com/gogits/gogs/custom
|
||||
fi
|
||||
cp -r /root/tempgogs/home/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 981
|
||||
fi
|
||||
echo $"Restoring Gogs repos"
|
||||
restore_directory_from_usb /root/tempgogsrepos gogsrepos
|
||||
cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 67574
|
||||
fi
|
||||
echo $"Restoring Gogs authorized_keys"
|
||||
restore_directory_from_usb /root/tempgogsssh gogsssh
|
||||
if [ ! -d /home/git/.ssh ]; then
|
||||
mkdir /home/git/.ssh
|
||||
fi
|
||||
cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 8463
|
||||
fi
|
||||
rm -rf /root/tempgogs
|
||||
rm -rf /root/tempgogsrepos
|
||||
rm -rf /root/tempgogsssh
|
||||
chown -R git:git /home/git
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_wiki {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'wiki' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ $WIKI_DOMAIN_NAME ]; then
|
||||
echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}"
|
||||
restore_directory_from_usb /root/tempwiki wiki
|
||||
cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 868
|
||||
fi
|
||||
restore_directory_from_usb /root/tempwiki2 wiki2
|
||||
cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 869
|
||||
fi
|
||||
rm -rf /root/tempwiki
|
||||
rm -rf /root/tempwiki2
|
||||
chown -R www-data:www-data /var/lib/dokuwiki/*
|
||||
# Ensure that the bundled SSL cert is being used
|
||||
if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then
|
||||
sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME}
|
||||
fi
|
||||
if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then
|
||||
ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key
|
||||
ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem
|
||||
fi
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'wiki' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ $WIKI_DOMAIN_NAME ]; then
|
||||
echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}"
|
||||
restore_directory_from_usb /root/tempwiki wiki
|
||||
cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 868
|
||||
fi
|
||||
restore_directory_from_usb /root/tempwiki2 wiki2
|
||||
cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 869
|
||||
fi
|
||||
rm -rf /root/tempwiki
|
||||
rm -rf /root/tempwiki2
|
||||
chown -R www-data:www-data /var/lib/dokuwiki/*
|
||||
# Ensure that the bundled SSL cert is being used
|
||||
if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then
|
||||
sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME}
|
||||
fi
|
||||
if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then
|
||||
ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key
|
||||
ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_blog {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'blog' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ $FULLBLOG_DOMAIN_NAME ]; then
|
||||
echo $"Restoring blog installation"
|
||||
restore_directory_from_usb /root/tempblog blog
|
||||
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 593
|
||||
fi
|
||||
rm -rf /root/tempblog
|
||||
if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
|
||||
echo $"No content directory found after restoring blog"
|
||||
unmount_drive
|
||||
exit 287
|
||||
fi
|
||||
chown -R www-data:www-data /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
# Ensure that the bundled SSL cert is being used
|
||||
if [ -f /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.bundle.crt ]; then
|
||||
sed -i "s|${FULLBLOG_DOMAIN_NAME}.crt|${FULLBLOG_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${FULLBLOG_DOMAIN_NAME}
|
||||
fi
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
|
||||
mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ -d /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME} ]; then
|
||||
ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${FULLBLOG_DOMAIN_NAME}.key
|
||||
ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.pem
|
||||
fi
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'blog' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ $FULLBLOG_DOMAIN_NAME ]; then
|
||||
echo $"Restoring blog installation"
|
||||
restore_directory_from_usb /root/tempblog blog
|
||||
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 593
|
||||
fi
|
||||
rm -rf /root/tempblog
|
||||
if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
|
||||
echo $"No content directory found after restoring blog"
|
||||
unmount_drive
|
||||
exit 287
|
||||
fi
|
||||
chown -R www-data:www-data /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
# Ensure that the bundled SSL cert is being used
|
||||
if [ -f /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.bundle.crt ]; then
|
||||
sed -i "s|${FULLBLOG_DOMAIN_NAME}.crt|${FULLBLOG_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${FULLBLOG_DOMAIN_NAME}
|
||||
fi
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
|
||||
mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ -d /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME} ]; then
|
||||
ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${FULLBLOG_DOMAIN_NAME}.key
|
||||
ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.pem
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_cjdns {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'cjdns' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $USB_MOUNT/backup/cjdns ]; then
|
||||
echo $"Restoring cjdns installation"
|
||||
restore_directory_from_usb /root/tempcjdns cjdns
|
||||
rm -rf /etc/cjdns
|
||||
cp -r /root/tempcjdns/etc/cjdns /etc/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 8472
|
||||
fi
|
||||
rm -rf /root/tempcjdns
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'cjdns' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $USB_MOUNT/backup/cjdns ]; then
|
||||
echo $"Restoring cjdns installation"
|
||||
restore_directory_from_usb /root/tempcjdns cjdns
|
||||
rm -rf /etc/cjdns
|
||||
cp -r /root/tempcjdns/etc/cjdns /etc/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 8472
|
||||
fi
|
||||
rm -rf /root/tempcjdns
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_email {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'email' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $USB_MOUNT/backup/mail ]; then
|
||||
for d in $USB_MOUNT/backup/mail/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
echo $"Restoring emails for $USERNAME"
|
||||
restore_directory_from_usb /root/tempmail mail/$USERNAME
|
||||
if [ ! -d /home/$USERNAME/Maildir ]; then
|
||||
mkdir /home/$USERNAME/Maildir
|
||||
fi
|
||||
tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 927
|
||||
fi
|
||||
rm -rf /root/tempmail
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'email' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $USB_MOUNT/backup/mail ]; then
|
||||
for d in $USB_MOUNT/backup/mail/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
echo $"Restoring emails for $USERNAME"
|
||||
restore_directory_from_usb /root/tempmail mail/$USERNAME
|
||||
if [ ! -d /home/$USERNAME/Maildir ]; then
|
||||
mkdir /home/$USERNAME/Maildir
|
||||
fi
|
||||
tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 927
|
||||
fi
|
||||
rm -rf /root/tempmail
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_dlna {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'dlna' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d /var/cache/minidlna ]; then
|
||||
if [ -d $USB_MOUNT/backup/dlna ]; then
|
||||
echo $"Restoring DLNA cache"
|
||||
restore_directory_from_usb /root/tempdlna dlna
|
||||
cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempdlna
|
||||
unmount_drive
|
||||
exit 982
|
||||
fi
|
||||
rm -rf /root/tempdlna
|
||||
fi
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'dlna' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d /var/cache/minidlna ]; then
|
||||
if [ -d $USB_MOUNT/backup/dlna ]; then
|
||||
echo $"Restoring DLNA cache"
|
||||
restore_directory_from_usb /root/tempdlna dlna
|
||||
cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempdlna
|
||||
unmount_drive
|
||||
exit 982
|
||||
fi
|
||||
rm -rf /root/tempdlna
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_voip {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'voip' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $USB_MOUNT/backup/voip ]; then
|
||||
echo $"Restoring VoIP settings"
|
||||
restore_directory_from_usb /root/tempvoip voip
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
unmount_drive
|
||||
exit 3679
|
||||
fi
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
unmount_drive
|
||||
exit 3679
|
||||
fi
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
unmount_drive
|
||||
exit 276
|
||||
fi
|
||||
rm -rf /root/tempvoip
|
||||
cp /etc/ssl/certs/mumble* /var/lib/mumble-server
|
||||
cp /etc/ssl/private/mumble* /var/lib/mumble-server
|
||||
chown -R mumble-server:mumble-server /var/lib/mumble-server
|
||||
service sipwitch restart
|
||||
service mumble-server restart
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'voip' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $USB_MOUNT/backup/voip ]; then
|
||||
echo $"Restoring VoIP settings"
|
||||
restore_directory_from_usb /root/tempvoip voip
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
unmount_drive
|
||||
exit 3679
|
||||
fi
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
unmount_drive
|
||||
exit 3679
|
||||
fi
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
unmount_drive
|
||||
exit 276
|
||||
fi
|
||||
rm -rf /root/tempvoip
|
||||
cp /etc/ssl/certs/mumble* /var/lib/mumble-server
|
||||
cp /etc/ssl/private/mumble* /var/lib/mumble-server
|
||||
chown -R mumble-server:mumble-server /var/lib/mumble-server
|
||||
service sipwitch restart
|
||||
service mumble-server restart
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_tox {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'tox' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $USB_MOUNT/backup/tox ]; then
|
||||
echo $"Restoring Tox node settings"
|
||||
restore_directory_from_usb / tox
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 6393
|
||||
fi
|
||||
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
||||
systemctl restart tox-bootstrapd.service
|
||||
if [ ! "$?" = "0" ]; then
|
||||
systemctl status tox-bootstrapd.service
|
||||
unmount_drive
|
||||
exit 59369
|
||||
fi
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'tox' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $USB_MOUNT/backup/tox ]; then
|
||||
echo $"Restoring Tox node settings"
|
||||
restore_directory_from_usb / tox
|
||||
if [ ! "$?" = "0" ]; then
|
||||
unmount_drive
|
||||
exit 6393
|
||||
fi
|
||||
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
||||
systemctl restart tox-bootstrapd.service
|
||||
if [ ! "$?" = "0" ]; then
|
||||
systemctl status tox-bootstrapd.service
|
||||
unmount_drive
|
||||
exit 59369
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function get_restore_app {
|
||||
if [ ${1} ]; then
|
||||
if [ ! -d /home/${1} ]; then
|
||||
RESTORE_APP=${1}
|
||||
echo $"Restore $RESTORE_APP"
|
||||
fi
|
||||
fi
|
||||
if [ ${1} ]; then
|
||||
if [ ! -d /home/${1} ]; then
|
||||
RESTORE_APP=${1}
|
||||
echo $"Restore $RESTORE_APP"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_restore_app ${2}
|
||||
|
|
|
@ -701,267 +701,267 @@ function restore_owncloud {
|
|||
fi
|
||||
if grep -q "Owncloud domain" $COMPLETION_FILE; then
|
||||
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
|
||||
restore_database_from_friend owncloudrepo $OWNCLOUD_DOMAIN_NAME
|
||||
restore_database_from_friend owncloud $OWNCLOUD_DOMAIN_NAME
|
||||
|
||||
if [ -d $SERVER_DIRECTORY/backup/owncloudrepofiles ]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/owncloudfiles ]; then
|
||||
echo $"Restoring Owncloud installation"
|
||||
cp -r /root/tempowncloudrepofiles/* /
|
||||
cp -r /root/tempowncloudfiles/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 1458
|
||||
fi
|
||||
rm -rf /root/tempowncloudrepofiles
|
||||
rm -rf /root/tempowncloudfiles
|
||||
fi
|
||||
|
||||
if [ -d $SERVER_DIRECTORY/backup/owncloudrepoconfig ]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/owncloudconfig ]; then
|
||||
echo $"Restoring Owncloud installation"
|
||||
cp -r /root/tempowncloudrepoconfig/* /
|
||||
cp -r /root/tempowncloudconfig/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 2571
|
||||
fi
|
||||
rm -rf /root/tempowncloudrepoconfig
|
||||
rm -rf /root/tempowncloudconfig
|
||||
fi
|
||||
|
||||
chown -R www-data:www-data /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs
|
||||
|
||||
chown -R www-data:www-data /var/www/owncloud
|
||||
|
||||
# re-index files
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ files:scan $USERNAME
|
||||
fi
|
||||
done
|
||||
fi
|
||||
/var/www/owncloud/occ files:scan $USERNAME
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_gogs {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'gogs' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if grep -q "Gogs domain" $COMPLETION_FILE; then
|
||||
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
|
||||
restore_database_from_friend gogs $GIT_DOMAIN_NAME
|
||||
if [ -d $SERVER_DIRECTORY/backup/gogs ]; then
|
||||
if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then
|
||||
mkdir -p /home/git/go/src/github.com/gogits/gogs/custom
|
||||
fi
|
||||
cp -r /root/tempgogs/home/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 5885
|
||||
fi
|
||||
echo $"Restoring Gogs repos"
|
||||
restore_directory_from_friend /root/tempgogsrepos gogsrepos
|
||||
cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 7649
|
||||
fi
|
||||
echo $"Restoring Gogs authorized_keys"
|
||||
restore_directory_from_friend /root/tempgogsssh gogsssh
|
||||
if [ ! -d /home/git/.ssh ]; then
|
||||
mkdir /home/git/.ssh
|
||||
fi
|
||||
cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 74239
|
||||
fi
|
||||
rm -rf /root/tempgogs
|
||||
rm -rf /root/tempgogsrepos
|
||||
rm -rf /root/tempgogsssh
|
||||
chown -R git:git /home/git
|
||||
fi
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'gogs' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if grep -q "Gogs domain" $COMPLETION_FILE; then
|
||||
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
|
||||
restore_database_from_friend gogs $GIT_DOMAIN_NAME
|
||||
if [ -d $SERVER_DIRECTORY/backup/gogs ]; then
|
||||
if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then
|
||||
mkdir -p /home/git/go/src/github.com/gogits/gogs/custom
|
||||
fi
|
||||
cp -r /root/tempgogs/home/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 5885
|
||||
fi
|
||||
echo $"Restoring Gogs repos"
|
||||
restore_directory_from_friend /root/tempgogsrepos gogsrepos
|
||||
cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 7649
|
||||
fi
|
||||
echo $"Restoring Gogs authorized_keys"
|
||||
restore_directory_from_friend /root/tempgogsssh gogsssh
|
||||
if [ ! -d /home/git/.ssh ]; then
|
||||
mkdir /home/git/.ssh
|
||||
fi
|
||||
cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 74239
|
||||
fi
|
||||
rm -rf /root/tempgogs
|
||||
rm -rf /root/tempgogsrepos
|
||||
rm -rf /root/tempgogsssh
|
||||
chown -R git:git /home/git
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_wiki {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'wiki' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/wiki ]; then
|
||||
WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}')
|
||||
echo $"Restoring Wiki installation $WIKI_DOMAIN_NAME"
|
||||
restore_directory_from_friend /root/tempwiki wiki
|
||||
cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 868
|
||||
fi
|
||||
restore_directory_from_friend /root/tempwiki2 wiki2
|
||||
cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 869
|
||||
fi
|
||||
rm -rf /root/tempwiki
|
||||
rm -rf /root/tempwiki2
|
||||
chown -R www-data:www-data /var/lib/dokuwiki/*
|
||||
# Ensure that the bundled SSL cert is being used
|
||||
if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then
|
||||
sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME}
|
||||
fi
|
||||
if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then
|
||||
ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key
|
||||
ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem
|
||||
fi
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'wiki' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/wiki ]; then
|
||||
WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}')
|
||||
echo $"Restoring Wiki installation $WIKI_DOMAIN_NAME"
|
||||
restore_directory_from_friend /root/tempwiki wiki
|
||||
cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 868
|
||||
fi
|
||||
restore_directory_from_friend /root/tempwiki2 wiki2
|
||||
cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 869
|
||||
fi
|
||||
rm -rf /root/tempwiki
|
||||
rm -rf /root/tempwiki2
|
||||
chown -R www-data:www-data /var/lib/dokuwiki/*
|
||||
# Ensure that the bundled SSL cert is being used
|
||||
if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then
|
||||
sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME}
|
||||
fi
|
||||
if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then
|
||||
ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key
|
||||
ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_blog {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'blog' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/blog ]; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
echo $"Restoring blog installation $FULLBLOG_DOMAIN_NAME"
|
||||
mkdir /root/tempblog
|
||||
restore_directory_from_friend /root/tempblog blog
|
||||
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 593
|
||||
fi
|
||||
rm -rf /root/tempblog
|
||||
if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
|
||||
echo $"No content directory found after restoring blog"
|
||||
exit 287
|
||||
fi
|
||||
# Ensure that the bundled SSL cert is being used
|
||||
if [ -f /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.bundle.crt ]; then
|
||||
sed -i "s|${FULLBLOG_DOMAIN_NAME}.crt|${FULLBLOG_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${FULLBLOG_DOMAIN_NAME}
|
||||
fi
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
|
||||
mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
|
||||
fi
|
||||
done
|
||||
if [ -d /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME} ]; then
|
||||
ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${FULLBLOG_DOMAIN_NAME}.key
|
||||
ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.pem
|
||||
fi
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'blog' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/blog ]; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
echo $"Restoring blog installation $FULLBLOG_DOMAIN_NAME"
|
||||
mkdir /root/tempblog
|
||||
restore_directory_from_friend /root/tempblog blog
|
||||
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 593
|
||||
fi
|
||||
rm -rf /root/tempblog
|
||||
if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
|
||||
echo $"No content directory found after restoring blog"
|
||||
exit 287
|
||||
fi
|
||||
# Ensure that the bundled SSL cert is being used
|
||||
if [ -f /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.bundle.crt ]; then
|
||||
sed -i "s|${FULLBLOG_DOMAIN_NAME}.crt|${FULLBLOG_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${FULLBLOG_DOMAIN_NAME}
|
||||
fi
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
|
||||
mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
|
||||
fi
|
||||
done
|
||||
if [ -d /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME} ]; then
|
||||
ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${FULLBLOG_DOMAIN_NAME}.key
|
||||
ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.pem
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_cjdns {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'cjdns' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/cjdns ]; then
|
||||
echo $"Restoring cjdns installation"
|
||||
restore_directory_from_friend /root/tempcjdns cjdns
|
||||
rm -rf /etc/cjdns
|
||||
cp -r /root/tempcjdns/etc/cjdns /etc/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 7438
|
||||
fi
|
||||
rm -rf /root/tempcjdns
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'cjdns' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/cjdns ]; then
|
||||
echo $"Restoring cjdns installation"
|
||||
restore_directory_from_friend /root/tempcjdns cjdns
|
||||
rm -rf /etc/cjdns
|
||||
cp -r /root/tempcjdns/etc/cjdns /etc/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 7438
|
||||
fi
|
||||
rm -rf /root/tempcjdns
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_voip {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'voip' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/voip ]; then
|
||||
echo $"Restoring VoIP settings"
|
||||
restore_directory_from_friend /root/tempvoip voip
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
exit 7823
|
||||
fi
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
exit 7823
|
||||
fi
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
exit 276
|
||||
fi
|
||||
rm -rf /root/tempvoip
|
||||
cp /etc/ssl/certs/mumble* /var/lib/mumble-server
|
||||
cp /etc/ssl/private/mumble* /var/lib/mumble-server
|
||||
chown -R mumble-server:mumble-server /var/lib/mumble-server
|
||||
service sipwitch restart
|
||||
service mumble-server restart
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'voip' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/voip ]; then
|
||||
echo $"Restoring VoIP settings"
|
||||
restore_directory_from_friend /root/tempvoip voip
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
exit 7823
|
||||
fi
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
exit 7823
|
||||
fi
|
||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf /root/tempvoip
|
||||
exit 276
|
||||
fi
|
||||
rm -rf /root/tempvoip
|
||||
cp /etc/ssl/certs/mumble* /var/lib/mumble-server
|
||||
cp /etc/ssl/private/mumble* /var/lib/mumble-server
|
||||
chown -R mumble-server:mumble-server /var/lib/mumble-server
|
||||
service sipwitch restart
|
||||
service mumble-server restart
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_tox {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'tox' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/tox ]; then
|
||||
echo $"Restoring Tox node settings"
|
||||
restore_directory_from_friend / tox
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 93653
|
||||
fi
|
||||
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
||||
systemctl restart tox-bootstrapd.service
|
||||
if [ ! "$?" = "0" ]; then
|
||||
systemctl status tox-bootstrapd.service
|
||||
exit 59369
|
||||
fi
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'tox' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/tox ]; then
|
||||
echo $"Restoring Tox node settings"
|
||||
restore_directory_from_friend / tox
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 93653
|
||||
fi
|
||||
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
||||
systemctl restart tox-bootstrapd.service
|
||||
if [ ! "$?" = "0" ]; then
|
||||
systemctl status tox-bootstrapd.service
|
||||
exit 59369
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_email {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'email' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/mail/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/mail/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
echo $"Restoring emails for $USERNAME"
|
||||
restore_directory_from_friend /root/tempmail mail/$USERNAME
|
||||
if [ ! -d /home/$USERNAME/Maildir ]; then
|
||||
mkdir /home/$USERNAME/Maildir
|
||||
fi
|
||||
tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 927
|
||||
fi
|
||||
rm -rf /root/tempmail
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'email' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/mail/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/mail/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
echo $"Restoring emails for $USERNAME"
|
||||
restore_directory_from_friend /root/tempmail mail/$USERNAME
|
||||
if [ ! -d /home/$USERNAME/Maildir ]; then
|
||||
mkdir /home/$USERNAME/Maildir
|
||||
fi
|
||||
tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 927
|
||||
fi
|
||||
rm -rf /root/tempmail
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function restore_dlna {
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'dlna' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d /var/cache/minidlna ]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/dlna ]; then
|
||||
echo $"Restoring DLNA cache"
|
||||
restore_directory_from_friend /root/tempdlna dlna
|
||||
cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 982
|
||||
fi
|
||||
rm -rf /root/tempdlna
|
||||
fi
|
||||
fi
|
||||
if [[ $RESTORE_APP != 'all' ]]; then
|
||||
if [[ $RESTORE_APP != 'dlna' ]]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [ -d /var/cache/minidlna ]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/dlna ]; then
|
||||
echo $"Restoring DLNA cache"
|
||||
restore_directory_from_friend /root/tempdlna dlna
|
||||
cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 982
|
||||
fi
|
||||
rm -rf /root/tempdlna
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Social key management
|
||||
|
|
|
@ -112,7 +112,7 @@ fi
|
|||
|
||||
if grep -q "install_owncloud_repo" $COMPLETION_FILE; then
|
||||
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
|
||||
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ user:delete $MY_USERNAME
|
||||
/var/www/owncloud/occ user:delete $MY_USERNAME
|
||||
fi
|
||||
|
||||
userdel -r $MY_USERNAME
|
||||
|
|
Loading…
Reference in New Issue