Use official owncloud deb

This commit is contained in:
Bob Mottram 2016-03-12 13:04:20 +00:00
parent 7b3b37e981
commit f2728c9780
7 changed files with 885 additions and 814 deletions

View File

@ -228,14 +228,14 @@ GVM_REPO="https://github.com/moovweb/gvm"
GVM_COMMIT='25ea8ae158e2861c92e2b22c458e60840157832f' GVM_COMMIT='25ea8ae158e2861c92e2b22c458e60840157832f'
# Domain name for Owncloud installation # Domain name for Owncloud installation
OWNCLOUD_REPO="https://github.com/owncloud/core"
OWNCLOUD_COMMIT='stable9'
OWNCLOUD_DOMAIN_NAME= OWNCLOUD_DOMAIN_NAME=
OWNCLOUD_CODE= OWNCLOUD_CODE=
OWNCLOUD_ONION_PORT=8088 OWNCLOUD_ONION_PORT=8088
OWNCLOUD_ADMIN_PASSWORD= OWNCLOUD_ADMIN_PASSWORD=
OWNCLOUD_MUSIC_APP_REPO="https://github.com/owncloud/music" OWNCLOUD_MUSIC_APP_REPO="https://github.com/owncloud/music"
OWNCLOUD_MUSIC_APP_COMMIT='0c0e1fadbe31a43f9c98d6a2a7b3960ff881ca0e' OWNCLOUD_MUSIC_APP_COMMIT='0c0e1fadbe31a43f9c98d6a2a7b3960ff881ca0e'
OWNCLOUD_PATH=/var/www/owncloud
OWNCLOUD_UPGRADE_PATH=/root/owncloud_upgrade
# Domain name for your wiki # Domain name for your wiki
WIKI_DOMAIN_NAME= WIKI_DOMAIN_NAME=
@ -616,6 +616,18 @@ function git_pull {
fi 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 { function create_database {
app_name="$1" app_name="$1"
app_admin_password="$2" app_admin_password="$2"
@ -6285,7 +6297,7 @@ function install_mariadb {
if [ -f $IMAGE_PASSWORD_FILE ]; then if [ -f $IMAGE_PASSWORD_FILE ]; then
MARIADB_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" MARIADB_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
MARIADB_PASSWORD="$(openssl rand -base64 32)" MARIADB_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
fi fi
echo "$MARIADB_PASSWORD" > $DATABASE_PASSWORD_FILE echo "$MARIADB_PASSWORD" > $DATABASE_PASSWORD_FILE
chmod 600 $DATABASE_PASSWORD_FILE chmod 600 $DATABASE_PASSWORD_FILE
@ -6391,15 +6403,15 @@ function install_owncloud_repo_music_app {
fi fi
# update to the next commit # 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 if grep -Fxq "install_owncloud_repo_music_app" $COMPLETION_FILE; then
return return
fi fi
cd /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/apps cd $OWNCLOUD_PATH/apps
git_clone $OWNCLOUD_MUSIC_APP_REPO Music 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 git checkout $OWNCLOUD_MUSIC_APP_COMMIT -b $OWNCLOUD_MUSIC_APP_COMMIT
if ! grep -q "Owncloud music app commit" $COMPLETION_FILE; then if ! grep -q "Owncloud music app commit" $COMPLETION_FILE; then
echo "Owncloud music app commit:$OWNCLOUD_MUSIC_APP_COMMIT" >> $COMPLETION_FILE 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 if [ ! $OWNCLOUD_DOMAIN_NAME ]; then
return return
fi fi
if [ ! -f /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/config.php ]; then if [ ! -f /var/www/owncloud/config/config.php ]; then
return return
fi fi
if [ ! -f /var/lib/tor/hidden_service_owncloud/hostname ]; then if [ ! -f /var/lib/tor/hidden_service_owncloud/hostname ]; then
return return
fi fi
OWNCLOUD_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_owncloud/hostname) 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}', 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, sed -i "s|'writable' => false,|'writable' => false,
), ),
1 => 1 =>
array ( array (
'path' => '/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/apps', 'path' => '/var/www/owncloud/apps',
'url' => '/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' echo $'Owncloud configured for onion site'
fi fi
} }
function upgrade_owncloud { function upgrade_owncloud_start {
# upgrades from the debian packaged version to a repo based version # copies data and config directories to a temporary upgrade directory
# The debian package for Owncloud is likely to be removed in future debian releases
if [ ! -d /etc/owncloud ]; then if [ ! -d /etc/owncloud ]; then
return return
fi fi
# remove any owncloud entries from completion
sed -i 's/install_owncloud.*/d' $COMPLETION_FILE
sed -i 's/owncloud.*/d' $COMPLETION_FILE
# create directories # create directories
if [ ! -d /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data ]; then if [ ! -d $OWNCLOUD_UPGRADE_PATH/data ]; then
mkdir /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data mkdir -p $OWNCLOUD_UPGRADE_PATH/data
fi fi
if [ ! -d /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config ]; then if [ ! -d $OWNCLOUD_UPGRADE_PATH/config ]; then
mkdir /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config mkdir -p $OWNCLOUD_UPGRADE_PATH/config
fi fi
# move the data # copy data to the temporary directory
if [ -d /var/lib/owncloud/data ]; then if [ -d /var/lib/owncloud/data ]; then
# copy users over cp -rf /var/lib/owncloud/data/* $OWNCLOUD_UPGRADE_PATH/data/
cp -rf /var/lib/owncloud/data/* /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data/
# set ownership to www-data
chown -R www-data:www-data /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data
fi fi
# move the config files # copy the config files to the temporary directory
if [ -d /etc/owncloud ]; then if [ -d /etc/owncloud ]; then
# copy users over cp -rf /etc/owncloud/* $OWNCLOUD_UPGRADE_PATH/config/
cp -rf /etc/owncloud/* /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config/ fi
# set ownership to www-data
chown -R www-data:www-data /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config # 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 fi
# re-index the files # re-index the files
for d in /home/*/ ; do for d in /home/*/ ; do
USRNAME=$(echo "$d" | awk -F '/' '{print $3}') USRNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USRNAME != "git" && $USRNAME != "mirrors" ]]; then if [[ $USRNAME != "git" && $USRNAME != "mirrors" ]]; then
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ files:scan $USRNAME $OWNCLOUD_PATH/occ files:scan $USRNAME
fi fi
done 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 # 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 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 return
@ -6554,20 +6612,12 @@ function install_owncloud_from_repo {
fi fi
fi fi
OWNCLOUD_PATH=/var/www/$OWNCLOUD_DOMAIN_NAME/htdocs # begin doing an upgrade if needed
upgrade_owncloud_start
# was this previously installed from a package?
WAS_INSTALLED_FROM_PACKAGE=
if [ -d /etc/owncloud ]; then
WAS_INSTALLED_FROM_PACKAGE='yes'
fi
# update to a new commit if needed
set_repo_commit $OWNCLOUD_PATH "Owncloud commit" "$OWNCLOUD_COMMIT" $OWNCLOUD_REPO
OWNCLOUD_COMPLETION_MSG1=$" *** ${PROJECT_NAME} $SYSTEM_TYPE is now installed ***" OWNCLOUD_COMPLETION_MSG1=$" *** ${PROJECT_NAME} $SYSTEM_TYPE is now installed ***"
OWNCLOUD_COMPLETION_MSG2=$"Open $OWNCLOUD_DOMAIN_NAME in a web browser to complete the setup" 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 if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" ]]; then
install_owncloud_repo_music_app install_owncloud_repo_music_app
backup_to_friends_servers backup_to_friends_servers
@ -6596,43 +6646,30 @@ function install_owncloud_from_repo {
echo $'Removed Apache installation after Owncloud install' echo $'Removed Apache installation after Owncloud install'
fi fi
# create the directory where owncloud will live # get the official owncloud deb package. Note that this is not the same as the one
if [ ! -d /var/www/$OWNCLOUD_DOMAIN_NAME ]; then # from the debian repos, and doesn't follow the debian packaging guidelines
mkdir /var/www/$OWNCLOUD_DOMAIN_NAME cd $INSTALL_DIR
fi wget -nv https://download.owncloud.org/download/repositories/stable/Debian_8.0/Release.key -O owncloud.key
apt-key add - < owncloud.key
# clone the owncloud repo if [ ! -f /etc/apt/sources.list.d/owncloud.list ]; then
cd /var/www/$OWNCLOUD_DOMAIN_NAME echo 'deb http://download.owncloud.org/download/repositories/stable/Debian_8.0/ /' >> /etc/apt/sources.list.d/owncloud.list
if [ -d $OWNCLOUD_PATH ]; then
if [ $WAS_INSTALLED_FROM_PACKAGE ]; then
# remove the existing link to /usr/share/owncloud
rm $OWNCLOUD_PATH
if [ -d $OWNCLOUD_PATH ]; then
echo $'Tried to unlink old owncloud, but link remains'
exit 67248
fi
fi
fi
git_clone $OWNCLOUD_REPO $OWNCLOUD_PATH
cd $OWNCLOUD_PATH
git checkout $OWNCLOUD_COMMIT -b $OWNCLOUD_COMMIT
# record the current commit
if ! grep -q "Owncloud commit" $COMPLETION_FILE; then
echo "Owncloud commit:$OWNCLOUD_COMMIT" >> $COMPLETION_FILE
else
sed -i "s/Owncloud commit.*/Owncloud commit:$OWNCLOUD_COMMIT/g" $COMPLETION_FILE
fi fi
apt-get update
apt-get -y install owncloud
install_mariadb install_mariadb
get_mariadb_password get_mariadb_password
if [ ! -d $OWNCLOUD_PATH ]; then
echo $'Owncloud was not installed'
exit 82584
fi
get_mariadb_owncloud_admin_password get_mariadb_owncloud_admin_password
if [ ! $OWNCLOUD_ADMIN_PASSWORD ]; then if [ ! $OWNCLOUD_ADMIN_PASSWORD ]; then
if [ -f $IMAGE_PASSWORD_FILE ]; then if [ -f $IMAGE_PASSWORD_FILE ]; then
OWNCLOUD_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" OWNCLOUD_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
OWNCLOUD_ADMIN_PASSWORD="$(openssl rand -base64 32)" OWNCLOUD_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
fi fi
fi fi
@ -6658,10 +6695,12 @@ function install_owncloud_from_repo {
chmod 600 /home/$MY_USERNAME/README chmod 600 /home/$MY_USERNAME/README
fi fi
if [ ! $WAS_INSTALLED_FROM_PACKAGE ]; then if [ -d /etc/owncloud ]; then
create_database owncloud "$OWNCLOUD_ADMIN_PASSWORD" remove_database owncloud
fi fi
create_database owncloud "$OWNCLOUD_ADMIN_PASSWORD"
if [[ $ONION_ONLY == "no" ]]; then if [[ $ONION_ONLY == "no" ]]; then
nginx_http_redirect $OWNCLOUD_DOMAIN_NAME nginx_http_redirect $OWNCLOUD_DOMAIN_NAME
echo 'server {' >> /etc/nginx/sites-available/$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 echo "Owncloud domain:$OWNCLOUD_DOMAIN_NAME" >> $COMPLETION_FILE
fi 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 if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" ]]; then
install_owncloud_repo_music_app install_owncloud_repo_music_app
@ -6994,7 +7066,7 @@ function install_gogs {
if [ -f $IMAGE_PASSWORD_FILE ]; then if [ -f $IMAGE_PASSWORD_FILE ]; then
GIT_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" GIT_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
GIT_ADMIN_PASSWORD="$(openssl rand -base64 32)" GIT_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
fi fi
fi fi
@ -7560,7 +7632,7 @@ function install_xmpp {
if [ -f $IMAGE_PASSWORD_FILE ]; then if [ -f $IMAGE_PASSWORD_FILE ]; then
XMPP_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" XMPP_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
XMPP_PASSWORD="$(openssl rand -base64 8)" XMPP_PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
fi fi
fi fi
prosodyctl register $MY_USERNAME $DEFAULT_DOMAIN_NAME $XMPP_PASSWORD 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/;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|;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 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 if [ -f $IMAGE_PASSWORD_FILE ]; then
IRC_OPERATOR_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" IRC_OPERATOR_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
IRC_OPERATOR_PASSWORD="$(openssl rand -base64 8)" IRC_OPERATOR_PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
fi fi
sed -i "s|;CloakHostSalt = abcdefghijklmnopqrstuvwxyz|CloakHostSalt = $IRC_SALT|g" /etc/ngircd/ngircd.conf 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 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 if [ -f $IMAGE_PASSWORD_FILE ]; then
WIKI_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" WIKI_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
WIKI_ADMIN_PASSWORD="$(openssl rand -base64 16)" WIKI_ADMIN_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
fi fi
fi fi
HASHED_WIKI_PASSWORD=$(echo -n "$WIKI_ADMIN_PASSWORD" | md5sum | awk -F ' ' '{print $1}') 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 if [ -f $IMAGE_PASSWORD_FILE ]; then
FULLBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" FULLBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
FULLBLOG_ADMIN_PASSWORD="$(openssl rand -base64 16)" FULLBLOG_ADMIN_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
fi fi
echo '' >> /home/$MY_USERNAME/README echo '' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README echo '' >> /home/$MY_USERNAME/README
@ -8606,7 +8678,7 @@ function install_rss_reader {
if [ -f $IMAGE_PASSWORD_FILE ]; then if [ -f $IMAGE_PASSWORD_FILE ]; then
RSS_READER_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" RSS_READER_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
RSS_READER_ADMIN_PASSWORD="$(openssl rand -base64 32)" RSS_READER_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
fi fi
fi fi
@ -8883,7 +8955,7 @@ function install_gnu_social {
if [ -f $IMAGE_PASSWORD_FILE ]; then if [ -f $IMAGE_PASSWORD_FILE ]; then
MICROBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" MICROBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
MICROBLOG_ADMIN_PASSWORD="$(openssl rand -base64 32)" MICROBLOG_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
fi fi
fi fi
@ -9430,7 +9502,7 @@ function install_search_engine {
# replace the secret key # replace the secret key
if ! grep "Search engine key" $COMPLETION_FILE; then 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 echo "Search engine key:${SEARCH_ENGINE_SECRET_KEY}" >> $COMPLETION_FILE
else else
SEARCH_ENGINE_SECRET_KEY=$(cat $COMPLETION_FILE | grep "Search engine key" | awk -F ':' '{print $2}') 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 if [ -f $IMAGE_PASSWORD_FILE ]; then
SEARCH_ENGINE_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" SEARCH_ENGINE_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
SEARCH_ENGINE_PASSWORD="$(openssl rand -base64 16)" SEARCH_ENGINE_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
fi fi
fi fi
echo "$SEARCH_ENGINE_PASSWORD" | htpasswd -i -s -c /etc/nginx/.htpasswd $MY_USERNAME 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 if [ -f $IMAGE_PASSWORD_FILE ]; then
HUBZILLA_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" HUBZILLA_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
HUBZILLA_ADMIN_PASSWORD="$(openssl rand -base64 32)" HUBZILLA_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
fi fi
echo '' >> /home/$MY_USERNAME/README echo '' >> /home/$MY_USERNAME/README
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 echo "\$a->config['system']['baseurl'] = 'http://${HUBZILLA_ONION_HOSTNAME}';" >> $HUBZILLA_PATH/.htconfig.php
fi fi
echo "\$a->config['system']['sitename'] = \"Hubzilla\";" >> $HUBZILLA_PATH/.htconfig.php 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']['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_policy'] = REGISTER_OPEN;" >> $HUBZILLA_PATH/.htconfig.php
echo "\$a->config['system']['register_text'] = '';" >> $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 if [ -f $IMAGE_PASSWORD_FILE ]; then
VOIP_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" VOIP_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else 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 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 fi
fi fi
@ -10617,7 +10689,7 @@ function install_sip {
if [ -f $IMAGE_PASSWORD_FILE ]; then if [ -f $IMAGE_PASSWORD_FILE ]; then
SIP_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" SIP_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else else
SIP_SERVER_PASSWORD="$(openssl rand -base64 10)" SIP_SERVER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)"
fi fi
fi fi
@ -10827,8 +10899,7 @@ script_for_attaching_usb_drive
install_web_server install_web_server
install_web_server_access_control install_web_server_access_control
configure_firewall_for_web_server configure_firewall_for_web_server
install_owncloud_from_repo install_owncloud_official_deb
upgrade_owncloud
install_owncloud_repo_music_app install_owncloud_repo_music_app
configure_owncloud_onion_site configure_owncloud_onion_site
upgrade_golang upgrade_golang

View File

@ -279,7 +279,7 @@ fi
if grep -q "install_owncloud_repo" $COMPLETION_FILE; then if grep -q "install_owncloud_repo" $COMPLETION_FILE; then
export OC_PASS="$NEW_USER_PASSWORD" export OC_PASS="$NEW_USER_PASSWORD"
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}') 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 if [ ! "$?" = "0" ]; then
echo 'Owncloud user could not be added' echo 'Owncloud user could not be added'
if grep -q "install_xmpp" $COMPLETION_FILE; then if grep -q "install_xmpp" $COMPLETION_FILE; then

View File

@ -370,9 +370,9 @@ function backup_directories {
"none, none, /var/lib/tox-bootstrapd, tox" "none, none, /var/lib/tox-bootstrapd, tox"
"/var/www/${MICROBLOG_DOMAIN_NAME}, gnusocial, /root/tempgnusocialdata, gnusocialdata" "/var/www/${MICROBLOG_DOMAIN_NAME}, gnusocial, /root/tempgnusocialdata, gnusocialdata"
"none, none, /var/www/${MICROBLOG_DOMAIN_NAME}/htdocs, gnusocial" "none, none, /var/www/${MICROBLOG_DOMAIN_NAME}/htdocs, gnusocial"
"/var/www/${OWNCLOUD_DOMAIN_NAME}, owncloud, /root/tempowncloudrepodata, owncloudrepodata" "/var/www/owncloud, owncloud, /root/tempownclouddata, ownclouddata"
"none, none, /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data, owncloudrepofiles" "none, none, /var/www/owncloud/data, owncloudfiles"
"none, none, /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config, owncloudrepoconfig" "none, none, /var/www/owncloud/config, owncloudconfig"
"/var/www/${HUBZILLA_DOMAIN_NAME}, hubzilla, /root/temphubzilladata, hubzilladata" "/var/www/${HUBZILLA_DOMAIN_NAME}, hubzilla, /root/temphubzilladata, hubzilladata"
"none, none, /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs, hubzilla" "none, none, /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs, hubzilla"
"none, none, /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs, blog" "none, none, /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs, blog"
@ -530,9 +530,9 @@ function valid_backup_destination {
"$destination_dir" == "ssl" || \ "$destination_dir" == "ssl" || \
"$destination_dir" == "ttrss" || \ "$destination_dir" == "ttrss" || \
"$destination_dir" == "blog" || \ "$destination_dir" == "blog" || \
"$destination_dir" == "owncloudrepofiles" || \ "$destination_dir" == "owncloudfiles" || \
"$destination_dir" == "owncloudrepoconfig" || \ "$destination_dir" == "owncloudconfig" || \
"$destination_dir" == "owncloudrepodata" || \ "$destination_dir" == "ownclouddata" || \
"$destination_dir" == "mailinglist" ]]; then "$destination_dir" == "mailinglist" ]]; then
is_valid="no" is_valid="no"
fi fi

View File

@ -330,332 +330,332 @@ function backup_owncloud {
if [ -d /etc/owncloud ]; then if [ -d /etc/owncloud ]; then
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}') OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
suspend_site ${OWNCLOUD_DOMAIN_NAME} suspend_site ${OWNCLOUD_DOMAIN_NAME}
backup_database_to_friend owncloudrepo backup_database_to_friend owncloud
backup_directory_to_friend /root/tempowncloudrepodata owncloudrepodata backup_directory_to_friend /root/tempownclouddata ownclouddata
echo $"Backing up Owncloud data" echo $"Backing up Owncloud data"
if [ -d /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data ]; then if [ -d /var/www/owncloud/data ]; then
backup_directory_to_friend /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/data owncloudrepofiles backup_directory_to_friend /var/www/owncloud/data owncloudfiles
fi fi
backup_directory_to_friend /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/config owncloudrepoconfig backup_directory_to_friend /var/www/owncloud/config owncloudconfig
restart_site restart_site
fi fi
} }
function backup_gogs { function backup_gogs {
if [ -d /home/git/go/src/github.com/gogits ]; then if [ -d /home/git/go/src/github.com/gogits ]; then
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}') GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
suspend_site ${GIT_DOMAIN_NAME} suspend_site ${GIT_DOMAIN_NAME}
backup_database_to_friend gogs backup_database_to_friend gogs
backup_directory_to_friend /root/tempgogsdata gogsdata backup_directory_to_friend /root/tempgogsdata gogsdata
echo $"Obtaining Gogs settings backup" echo $"Obtaining Gogs settings backup"
backup_directory_to_friend /home/git/go/src/github.com/gogits/gogs/custom gogs backup_directory_to_friend /home/git/go/src/github.com/gogits/gogs/custom gogs
echo $"Obtaining Gogs repos backup" echo $"Obtaining Gogs repos backup"
mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/bob mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/bob
backup_directory_to_friend /home/git/gogs-repositories gogsrepos backup_directory_to_friend /home/git/gogs-repositories gogsrepos
echo $"Obtaining Gogs authorized_keys backup" echo $"Obtaining Gogs authorized_keys backup"
backup_directory_to_friend /home/git/.ssh gogsssh backup_directory_to_friend /home/git/.ssh gogsssh
restart_site restart_site
fi fi
} }
function backup_wiki { function backup_wiki {
if [ -d /etc/dokuwiki ]; then if [ -d /etc/dokuwiki ]; then
echo $"Backing up wiki" echo $"Backing up wiki"
backup_directory_to_friend /var/lib/dokuwiki wiki backup_directory_to_friend /var/lib/dokuwiki wiki
backup_directory_to_friend /etc/dokuwiki wiki2 backup_directory_to_friend /etc/dokuwiki wiki2
fi fi
} }
function backup_blog { function backup_blog {
if grep -q "Blog domain" $COMPLETION_FILE; then if grep -q "Blog domain" $COMPLETION_FILE; then
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}') FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME} ]; then if [ -d /var/www/${FULLBLOG_DOMAIN_NAME} ]; then
echo $"Backing up blog" echo $"Backing up blog"
backup_directory_to_friend /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs blog backup_directory_to_friend /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs blog
else else
echo $"Blog domain specified but not found in /var/www/${FULLBLOG_DOMAIN_NAME}" echo $"Blog domain specified but not found in /var/www/${FULLBLOG_DOMAIN_NAME}"
exit 2578 exit 2578
fi fi
fi fi
} }
function backup_certs { function backup_certs {
if [ -d /etc/ssl ]; then if [ -d /etc/ssl ]; then
echo $"Backing up certificates" echo $"Backing up certificates"
backup_directory_to_friend /etc/ssl ssl backup_directory_to_friend /etc/ssl ssl
fi fi
} }
function backup_mailing_list { function backup_mailing_list {
if [ -d /var/spool/mlmmj ]; then if [ -d /var/spool/mlmmj ]; then
echo $"Backing up the public mailing list" echo $"Backing up the public mailing list"
backup_directory_to_friend /var/spool/mlmmj mailinglist backup_directory_to_friend /var/spool/mlmmj mailinglist
fi fi
} }
function backup_xmpp { function backup_xmpp {
if [ -d /var/lib/prosody ]; then if [ -d /var/lib/prosody ]; then
echo $"Backing up the XMPP settings" echo $"Backing up the XMPP settings"
backup_directory_to_friend /var/lib/prosody xmpp backup_directory_to_friend /var/lib/prosody xmpp
fi fi
} }
function backup_web_server { function backup_web_server {
if [ -d /etc/nginx ]; then if [ -d /etc/nginx ]; then
echo $"Backing up web settings" echo $"Backing up web settings"
backup_directory_to_friend /etc/nginx/sites-available web backup_directory_to_friend /etc/nginx/sites-available web
fi fi
} }
function backup_admin_readme { function backup_admin_readme {
if [ -f /home/$ADMIN_USERNAME/README ]; then if [ -f /home/$ADMIN_USERNAME/README ]; then
echo $"Backing up README" echo $"Backing up README"
if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then
mkdir -p /home/$ADMIN_USERNAME/tempbackup mkdir -p /home/$ADMIN_USERNAME/tempbackup
fi fi
cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup
backup_directory_to_friend /home/$ADMIN_USERNAME/tempbackup readme backup_directory_to_friend /home/$ADMIN_USERNAME/tempbackup readme
fi fi
} }
function backup_ipfs { function backup_ipfs {
if [ -d /home/$ADMIN_USERNAME/.ipfs ]; then if [ -d /home/$ADMIN_USERNAME/.ipfs ]; then
echo $"Backing up IPFS" echo $"Backing up IPFS"
backup_directory_to_friend /home/$ADMIN_USERNAME/.ipfs ipfs backup_directory_to_friend /home/$ADMIN_USERNAME/.ipfs ipfs
fi fi
} }
function backup_dlna { function backup_dlna {
if [ -d /var/cache/minidlna ]; then if [ -d /var/cache/minidlna ]; then
echo $"Backing up DLNA cache" echo $"Backing up DLNA cache"
backup_directory_to_friend /var/cache/minidlna dlna backup_directory_to_friend /var/cache/minidlna dlna
fi fi
} }
function backup_voip { function backup_voip {
if [ -f /etc/mumble-server.ini ]; then if [ -f /etc/mumble-server.ini ]; then
echo $"Backing up VoIP settings" echo $"Backing up VoIP settings"
if [ ! -d /root/tempvoipbackup ]; then if [ ! -d /root/tempvoipbackup ]; then
mkdir -p /root/tempvoipbackup mkdir -p /root/tempvoipbackup
fi fi
cp -f /etc/mumble-server.ini /root/tempvoipbackup cp -f /etc/mumble-server.ini /root/tempvoipbackup
cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup
cp -f /etc/sipwitch.conf /root/tempvoipbackup cp -f /etc/sipwitch.conf /root/tempvoipbackup
backup_directory_to_friend /root/tempvoipbackup voip backup_directory_to_friend /root/tempvoipbackup voip
fi fi
} }
function backup_tox { function backup_tox {
if [ -d /var/lib/tox-bootstrapd ]; then if [ -d /var/lib/tox-bootstrapd ]; then
echo "Backing up Tox node settings" echo "Backing up Tox node settings"
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
rm -rf /var/lib/tox-bootstrapd/Maildir rm -rf /var/lib/tox-bootstrapd/Maildir
fi fi
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
backup_directory_to_friend /var/lib/tox-bootstrapd tox backup_directory_to_friend /var/lib/tox-bootstrapd tox
fi fi
} }
function backup_mariadb { function backup_mariadb {
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
if [ ! -d /root/tempmariadb ]; then if [ ! -d /root/tempmariadb ]; then
mkdir /root/tempmariadb mkdir /root/tempmariadb
fi fi
mysqldump --password=$DATABASE_PASSWORD mysql user > /root/tempmariadb/mysql.sql mysqldump --password=$DATABASE_PASSWORD mysql user > /root/tempmariadb/mysql.sql
if [ ! -s /root/tempmariadb/mysql.sql ]; then if [ ! -s /root/tempmariadb/mysql.sql ]; then
echo $"Unable to backup MariaDB settings" echo $"Unable to backup MariaDB settings"
rm -rf /root/tempmariadb rm -rf /root/tempmariadb
# Send a warning email # Send a warning email
echo $"Unable to export database settings" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS echo $"Unable to export database settings" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS
exit 653 exit 653
fi fi
echo "$DATABASE_PASSWORD" > /root/tempmariadb/db echo "$DATABASE_PASSWORD" > /root/tempmariadb/db
chmod 400 /root/tempmariadb/db chmod 400 /root/tempmariadb/db
backup_directory_to_friend /root/tempmariadb mariadb backup_directory_to_friend /root/tempmariadb mariadb
fi fi
} }
# Returns the filename of a key share # Returns the filename of a key share
function get_key_share { function get_key_share {
no_of_shares=$1 no_of_shares=$1
USERNAME="$2" USERNAME="$2"
REMOTE_DOMAIN="$3" REMOTE_DOMAIN="$3"
# Get a share index based on the supplied domain name # Get a share index based on the supplied domain name
# This ensures that the same share is always given to the same domain # This ensures that the same share is always given to the same domain
sharenumstr=$(md5sum <<< "$REMOTE_DOMAIN") sharenumstr=$(md5sum <<< "$REMOTE_DOMAIN")
share_index=$(echo $((0x${sharenumstr%% *} % ${no_of_shares})) | tr -d -) share_index=$(echo $((0x${sharenumstr%% *} % ${no_of_shares})) | tr -d -)
# get the filename # get the filename
share_files=(/home/$USERNAME/.gnupg_fragments/keyshare.asc.*) share_files=(/home/$USERNAME/.gnupg_fragments/keyshare.asc.*)
share_filename=${share_files[share_index]} share_filename=${share_files[share_index]}
echo "$share_filename" echo "$share_filename"
} }
function disperse_key_shares { function disperse_key_shares {
USERNAME=$1 USERNAME=$1
REMOTE_DOMAIN=$2 REMOTE_DOMAIN=$2
REMOTE_SSH_PORT=$3 REMOTE_SSH_PORT=$3
REMOTE_PASSWORD=$4 REMOTE_PASSWORD=$4
REMOTE_SERVER=$5 REMOTE_SERVER=$5
if [ -d /home/$USERNAME/.gnupg_fragments ]; then if [ -d /home/$USERNAME/.gnupg_fragments ]; then
if [ $REMOTE_DOMAIN ]; then if [ $REMOTE_DOMAIN ]; then
cd /home/$USERNAME/.gnupg_fragments cd /home/$USERNAME/.gnupg_fragments
no_of_shares=$(ls -afq keyshare.asc.* | wc -l) no_of_shares=$(ls -afq keyshare.asc.* | wc -l)
if (( no_of_shares > 1 )); then if (( no_of_shares > 1 )); then
share_filename=$(get_key_share $no_of_shares "$USERNAME" "$REMOTE_DOMAIN") share_filename=$(get_key_share $no_of_shares "$USERNAME" "$REMOTE_DOMAIN")
# create a temp directory containing the share # create a temp directory containing the share
temp_key_share_dir=/home/$USERNAME/tempkey temp_key_share_dir=/home/$USERNAME/tempkey
temp_key_share_fragments=$temp_key_share_dir/.gnupg_fragments_${USERNAME} temp_key_share_fragments=$temp_key_share_dir/.gnupg_fragments_${USERNAME}
mkdir -p $temp_key_share_fragments mkdir -p $temp_key_share_fragments
cp $share_filename $temp_key_share_fragments/ cp $share_filename $temp_key_share_fragments/
# copy the fragments directory to the remote server # copy the fragments directory to the remote server
/usr/bin/sshpass -p "$REMOTE_PASSWORD" \ /usr/bin/sshpass -p "$REMOTE_PASSWORD" \
scp -r -P $REMOTE_SSH_PORT $temp_key_share_fragments $REMOTE_SERVER scp -r -P $REMOTE_SSH_PORT $temp_key_share_fragments $REMOTE_SERVER
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
# Send a warning email # Send a warning email
echo "Key share to $REMOTE_SERVER failed" | \ echo "Key share to $REMOTE_SERVER failed" | \
mail -s "${PROJECT_NAME} social key management" $MY_EMAIL_ADDRESS mail -s "${PROJECT_NAME} social key management" $MY_EMAIL_ADDRESS
else else
# Send a confirmation email # Send a confirmation email
echo "Key ${share_filename} shared to $REMOTE_SERVER" | \ echo "Key ${share_filename} shared to $REMOTE_SERVER" | \
mail -s "${PROJECT_NAME} social key management" $MY_EMAIL_ADDRESS mail -s "${PROJECT_NAME} social key management" $MY_EMAIL_ADDRESS
fi fi
# remove the temp file/directory # remove the temp file/directory
shred -zu $temp_key_share_fragments/* shred -zu $temp_key_share_fragments/*
rm -rf $temp_key_share_dir rm -rf $temp_key_share_dir
fi fi
fi fi
fi fi
} }
function valid_backup_destination { function valid_backup_destination {
destination_dir="$1" destination_dir="$1"
is_valid="yes" is_valid="yes"
if [[ "$destination_dir" == "hubzilla" || \ if [[ "$destination_dir" == "hubzilla" || \
"$destination_dir" == "hubzilladata" || \ "$destination_dir" == "hubzilladata" || \
"$destination_dir" == "gogs" || \ "$destination_dir" == "gogs" || \
"$destination_dir" == "gogsrepos" || \ "$destination_dir" == "gogsrepos" || \
"$destination_dir" == "gogsssh" || \ "$destination_dir" == "gogsssh" || \
"$destination_dir" == "gnusocial" || \ "$destination_dir" == "gnusocial" || \
"$destination_dir" == "gnusocialdata" || \ "$destination_dir" == "gnusocialdata" || \
"$destination_dir" == "mariadb" || \ "$destination_dir" == "mariadb" || \
"$destination_dir" == "config" || \ "$destination_dir" == "config" || \
"$destination_dir" == "letsencrypt" || \ "$destination_dir" == "letsencrypt" || \
"$destination_dir" == "wiki" || \ "$destination_dir" == "wiki" || \
"$destination_dir" == "wiki2" || \ "$destination_dir" == "wiki2" || \
"$destination_dir" == "xmpp" || \ "$destination_dir" == "xmpp" || \
"$destination_dir" == "ipfs" || \ "$destination_dir" == "ipfs" || \
"$destination_dir" == "dlna" || \ "$destination_dir" == "dlna" || \
"$destination_dir" == "tox" || \ "$destination_dir" == "tox" || \
"$destination_dir" == "ssl" || \ "$destination_dir" == "ssl" || \
"$destination_dir" == "blog" || \ "$destination_dir" == "blog" || \
"$destination_dir" == "owncloudrepofiles" || \ "$destination_dir" == "owncloudfiles" || \
"$destination_dir" == "owncloudrepoconfig" || \ "$destination_dir" == "owncloudconfig" || \
"$destination_dir" == "owncloudrepodata" || \ "$destination_dir" == "ownclouddata" || \
"$destination_dir" == "mailinglist" ]]; then "$destination_dir" == "mailinglist" ]]; then
is_valid="no" is_valid="no"
fi fi
echo $is_valid echo $is_valid
} }
function backup_extra_directories { function backup_extra_directories {
if [ ! -f $BACKUP_EXTRA_DIRECTORIES ]; then if [ ! -f $BACKUP_EXTRA_DIRECTORIES ]; then
return return
fi fi
echo $"Backing up some additional directories" echo $"Backing up some additional directories"
while read backup_line while read backup_line
do do
backup_dir=$(echo "$backup_line" | awk -F ',' '{print $1}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') backup_dir=$(echo "$backup_line" | awk -F ',' '{print $1}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [ -d "$backup_dir" ]; then if [ -d "$backup_dir" ]; then
destination_dir=$(echo "$backup_line" | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') destination_dir=$(echo "$backup_line" | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [[ $(valid_backup_destination "$destination_dir") == "yes" ]]; then if [[ $(valid_backup_destination "$destination_dir") == "yes" ]]; then
backup_directory_to_friend "$backup_dir" "$destination_dir" backup_directory_to_friend "$backup_dir" "$destination_dir"
else else
echo $"WARNING: The backup directory $destination_dir is already used." echo $"WARNING: The backup directory $destination_dir is already used."
echo $"Choose a different destination name for backing up $backup_dir" echo $"Choose a different destination name for backing up $backup_dir"
fi fi
else else
echo $"WARNING: Directory $backup_dir does not exist" echo $"WARNING: Directory $backup_dir does not exist"
fi fi
done <$BACKUP_EXTRA_DIRECTORIES done <$BACKUP_EXTRA_DIRECTORIES
} }
TEST_MODE="no" TEST_MODE="no"
if [[ "$1" == "test" ]]; then if [[ "$1" == "test" ]]; then
TEST_MODE="yes" TEST_MODE="yes"
fi fi
backup_configuration backup_configuration
if [[ $TEST_MODE == "no" ]]; then if [[ $TEST_MODE == "no" ]]; then
backup_users backup_users
backup_letsencrypt backup_letsencrypt
backup_tor backup_tor
backup_gnusocial backup_gnusocial
backup_rss_reader backup_rss_reader
backup_hubzilla backup_hubzilla
backup_owncloud backup_owncloud
backup_gogs backup_gogs
backup_wiki backup_wiki
backup_blog backup_blog
backup_certs backup_certs
backup_mailing_list backup_mailing_list
backup_xmpp backup_xmpp
backup_web_server backup_web_server
backup_admin_readme backup_admin_readme
backup_ipfs backup_ipfs
backup_dlna backup_dlna
backup_voip backup_voip
backup_tox backup_tox
backup_mariadb backup_mariadb
backup_extra_directories backup_extra_directories
fi fi
# For each remote server # For each remote server
while read remote_server while read remote_server
do do
# Get the server and its password # Get the server and its password
# Format is: # Format is:
# username@domain <port number> /home/username <ssh password> # username@domain <port number> /home/username <ssh password>
REMOTE_SERVER=$(echo "${remote_server}" | awk -F ' ' '{print $1}') REMOTE_SERVER=$(echo "${remote_server}" | awk -F ' ' '{print $1}')
if [ $REMOTE_SERVER ]; then if [ $REMOTE_SERVER ]; then
REMOTE_DOMAIN=$(echo "${remote_server}" | awk -F ' ' '{print $1}' | awk -F '@' '{print $2}') REMOTE_DOMAIN=$(echo "${remote_server}" | awk -F ' ' '{print $1}' | awk -F '@' '{print $2}')
REMOTE_SSH_PORT=$(echo "${remote_server}" | awk -F ' ' '{print $2}') REMOTE_SSH_PORT=$(echo "${remote_server}" | awk -F ' ' '{print $2}')
REMOTE_DIRECTORY=$(echo "${remote_server}" | awk -F ' ' '{print $3}') REMOTE_DIRECTORY=$(echo "${remote_server}" | awk -F ' ' '{print $3}')
REMOTE_PASSWORD=$(echo "${remote_server}" | awk -F ' ' '{print $4}') REMOTE_PASSWORD=$(echo "${remote_server}" | awk -F ' ' '{print $4}')
NOW=$(date +"%Y-%m-%d %H:%M:%S") NOW=$(date +"%Y-%m-%d %H:%M:%S")
REMOTE_SERVER=$REMOTE_SERVER:$REMOTE_DIRECTORY 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 # Social key management
for d in /home/*/ ; do for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}') USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USERNAME != "mirrors" ]]; then if [[ $USERNAME != "git" && $USERNAME != "mirrors" ]]; then
disperse_key_shares $USERNAME $REMOTE_DOMAIN $REMOTE_SSH_PORT "$REMOTE_PASSWORD" $REMOTE_SERVER disperse_key_shares $USERNAME $REMOTE_DOMAIN $REMOTE_SSH_PORT "$REMOTE_PASSWORD" $REMOTE_SERVER
fi fi
done done
if [[ $TEST_MODE == "yes" ]]; then 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" echo "rsync -ratlzv --rsh=\"/usr/bin/sshpass -p '$REMOTE_PASSWORD' ssh -p $REMOTE_SSH_PORT -o StrictHostKeyChecking=no\" $SERVER_DIRECTORY/backup $REMOTE_SERVER"
fi fi
rsync -ratlzv --rsh="/usr/bin/sshpass -p \"$REMOTE_PASSWORD\" ssh -p $REMOTE_SSH_PORT -o StrictHostKeyChecking=no" $SERVER_DIRECTORY/backup $REMOTE_SERVER 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 if [ ! "$?" = "0" ]; then
echo "$NOW Backup to $REMOTE_SERVER failed" >> /var/log/remotebackups.log echo "$NOW Backup to $REMOTE_SERVER failed" >> /var/log/remotebackups.log
# Send a warning email # Send a warning email
echo "Backup to $REMOTE_SERVER failed" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS echo "Backup to $REMOTE_SERVER failed" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS
else else
echo "$NOW Backed up to $REMOTE_SERVER" >> /var/log/remotebackups.log echo "$NOW Backed up to $REMOTE_SERVER" >> /var/log/remotebackups.log
fi fi
fi fi
done < /home/${ADMIN_USERNAME}/backup.list done < /home/${ADMIN_USERNAME}/backup.list

View File

@ -826,292 +826,292 @@ function restore_owncloud {
fi fi
fi fi
if [ $OWNCLOUD_DOMAIN_NAME ]; then if [ $OWNCLOUD_DOMAIN_NAME ]; then
restore_database owncloudrepo $OWNCLOUD_DOMAIN_NAME restore_database owncloud $OWNCLOUD_DOMAIN_NAME
if [ -d $USB_MOUNT/backup/owncloudrepofiles ]; then if [ -d $USB_MOUNT/backup/owncloudfiles ]; then
restore_directory_from_usb /root/tempowncloudrepofiles owncloudrepofiles restore_directory_from_usb /root/tempowncloudfiles owncloudfiles
cp -r /root/tempowncloudrepofiles/* / cp -r /root/tempowncloudfiles/* /
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
unmount_drive unmount_drive
exit 982 exit 982
fi fi
rm -rf /root/tempowncloudrepofiles rm -rf /root/tempowncloudfiles
fi fi
if [ -d $USB_MOUNT/backup/owncloudrepoconfig ]; then if [ -d $USB_MOUNT/backup/owncloudconfig ]; then
restore_directory_from_usb /root/tempowncloudrepoconfig owncloudrepoconfig restore_directory_from_usb /root/tempowncloudconfig owncloudconfig
cp -r /root/tempowncloudrepoconfig/* / cp -r /root/tempowncloudconfig/* /
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
unmount_drive unmount_drive
exit 7825 exit 7825
fi fi
rm -rf /root/tempowncloudrepoconfig rm -rf /root/tempowncloudconfig
fi fi
# re-index the files # re-index the files
chown -R www-data:www-data /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs chown -R www-data:www-data /var/www/owncloud
for d in /home/*/ ; do for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}') USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ files:scan $USERNAME /var/www/owncloud/occ files:scan $USERNAME
fi fi
done done
fi fi
} }
function restore_gogs { function restore_gogs {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'gogs' ]]; then if [[ $RESTORE_APP != 'gogs' ]]; then
return return
fi fi
fi fi
if [ $GIT_DOMAIN_NAME ]; then if [ $GIT_DOMAIN_NAME ]; then
restore_database gogs ${GIT_DOMAIN_NAME} restore_database gogs ${GIT_DOMAIN_NAME}
if [ -d $USB_MOUNT/backup/gogs ]; then if [ -d $USB_MOUNT/backup/gogs ]; then
echo $"Restoring Gogs settings" echo $"Restoring Gogs settings"
if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then
mkdir -p /home/git/go/src/github.com/gogits/gogs/custom mkdir -p /home/git/go/src/github.com/gogits/gogs/custom
fi fi
cp -r /root/tempgogs/home/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom 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 if [ ! "$?" = "0" ]; then
unmount_drive unmount_drive
exit 981 exit 981
fi fi
echo $"Restoring Gogs repos" echo $"Restoring Gogs repos"
restore_directory_from_usb /root/tempgogsrepos gogsrepos restore_directory_from_usb /root/tempgogsrepos gogsrepos
cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/ cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
unmount_drive unmount_drive
exit 67574 exit 67574
fi fi
echo $"Restoring Gogs authorized_keys" echo $"Restoring Gogs authorized_keys"
restore_directory_from_usb /root/tempgogsssh gogsssh restore_directory_from_usb /root/tempgogsssh gogsssh
if [ ! -d /home/git/.ssh ]; then if [ ! -d /home/git/.ssh ]; then
mkdir /home/git/.ssh mkdir /home/git/.ssh
fi fi
cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/ cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
unmount_drive unmount_drive
exit 8463 exit 8463
fi fi
rm -rf /root/tempgogs rm -rf /root/tempgogs
rm -rf /root/tempgogsrepos rm -rf /root/tempgogsrepos
rm -rf /root/tempgogsssh rm -rf /root/tempgogsssh
chown -R git:git /home/git chown -R git:git /home/git
fi fi
fi fi
} }
function restore_wiki { function restore_wiki {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'wiki' ]]; then if [[ $RESTORE_APP != 'wiki' ]]; then
return return
fi fi
fi fi
if [ $WIKI_DOMAIN_NAME ]; then if [ $WIKI_DOMAIN_NAME ]; then
echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}" echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}"
restore_directory_from_usb /root/tempwiki wiki restore_directory_from_usb /root/tempwiki wiki
cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/ cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
unmount_drive unmount_drive
exit 868 exit 868
fi fi
restore_directory_from_usb /root/tempwiki2 wiki2 restore_directory_from_usb /root/tempwiki2 wiki2
cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/ cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
unmount_drive unmount_drive
exit 869 exit 869
fi fi
rm -rf /root/tempwiki rm -rf /root/tempwiki
rm -rf /root/tempwiki2 rm -rf /root/tempwiki2
chown -R www-data:www-data /var/lib/dokuwiki/* chown -R www-data:www-data /var/lib/dokuwiki/*
# Ensure that the bundled SSL cert is being used # Ensure that the bundled SSL cert is being used
if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then 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} sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME}
fi fi
if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then 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}/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 ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem
fi fi
fi fi
} }
function restore_blog { function restore_blog {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'blog' ]]; then if [[ $RESTORE_APP != 'blog' ]]; then
return return
fi fi
fi fi
if [ $FULLBLOG_DOMAIN_NAME ]; then if [ $FULLBLOG_DOMAIN_NAME ]; then
echo $"Restoring blog installation" echo $"Restoring blog installation"
restore_directory_from_usb /root/tempblog blog restore_directory_from_usb /root/tempblog blog
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/ cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
unmount_drive unmount_drive
exit 593 exit 593
fi fi
rm -rf /root/tempblog rm -rf /root/tempblog
if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
echo $"No content directory found after restoring blog" echo $"No content directory found after restoring blog"
unmount_drive unmount_drive
exit 287 exit 287
fi fi
chown -R www-data:www-data /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs chown -R www-data:www-data /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
# Ensure that the bundled SSL cert is being used # Ensure that the bundled SSL cert is being used
if [ -f /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.bundle.crt ]; then 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} sed -i "s|${FULLBLOG_DOMAIN_NAME}.crt|${FULLBLOG_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${FULLBLOG_DOMAIN_NAME}
fi fi
for d in /home/*/ ; do for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}') USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; 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 mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
fi fi
fi fi
done done
if [ -d /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME} ]; then 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}/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 ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.pem
fi fi
fi fi
} }
function restore_cjdns { function restore_cjdns {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'cjdns' ]]; then if [[ $RESTORE_APP != 'cjdns' ]]; then
return return
fi fi
fi fi
if [ -d $USB_MOUNT/backup/cjdns ]; then if [ -d $USB_MOUNT/backup/cjdns ]; then
echo $"Restoring cjdns installation" echo $"Restoring cjdns installation"
restore_directory_from_usb /root/tempcjdns cjdns restore_directory_from_usb /root/tempcjdns cjdns
rm -rf /etc/cjdns rm -rf /etc/cjdns
cp -r /root/tempcjdns/etc/cjdns /etc/ cp -r /root/tempcjdns/etc/cjdns /etc/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
unmount_drive unmount_drive
exit 8472 exit 8472
fi fi
rm -rf /root/tempcjdns rm -rf /root/tempcjdns
fi fi
} }
function restore_email { function restore_email {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'email' ]]; then if [[ $RESTORE_APP != 'email' ]]; then
return return
fi fi
fi fi
if [ -d $USB_MOUNT/backup/mail ]; then if [ -d $USB_MOUNT/backup/mail ]; then
for d in $USB_MOUNT/backup/mail/*/ ; do for d in $USB_MOUNT/backup/mail/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}') USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ ! -d /home/$USERNAME ]; then if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME ${PROJECT_NAME}-adduser $USERNAME
fi fi
echo $"Restoring emails for $USERNAME" echo $"Restoring emails for $USERNAME"
restore_directory_from_usb /root/tempmail mail/$USERNAME restore_directory_from_usb /root/tempmail mail/$USERNAME
if [ ! -d /home/$USERNAME/Maildir ]; then if [ ! -d /home/$USERNAME/Maildir ]; then
mkdir /home/$USERNAME/Maildir mkdir /home/$USERNAME/Maildir
fi fi
tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C / tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
unmount_drive unmount_drive
exit 927 exit 927
fi fi
rm -rf /root/tempmail rm -rf /root/tempmail
fi fi
done done
fi fi
} }
function restore_dlna { function restore_dlna {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'dlna' ]]; then if [[ $RESTORE_APP != 'dlna' ]]; then
return return
fi fi
fi fi
if [ -d /var/cache/minidlna ]; then if [ -d /var/cache/minidlna ]; then
if [ -d $USB_MOUNT/backup/dlna ]; then if [ -d $USB_MOUNT/backup/dlna ]; then
echo $"Restoring DLNA cache" echo $"Restoring DLNA cache"
restore_directory_from_usb /root/tempdlna dlna restore_directory_from_usb /root/tempdlna dlna
cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/ cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf /root/tempdlna rm -rf /root/tempdlna
unmount_drive unmount_drive
exit 982 exit 982
fi fi
rm -rf /root/tempdlna rm -rf /root/tempdlna
fi fi
fi fi
} }
function restore_voip { function restore_voip {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'voip' ]]; then if [[ $RESTORE_APP != 'voip' ]]; then
return return
fi fi
fi fi
if [ -d $USB_MOUNT/backup/voip ]; then if [ -d $USB_MOUNT/backup/voip ]; then
echo $"Restoring VoIP settings" echo $"Restoring VoIP settings"
restore_directory_from_usb /root/tempvoip voip restore_directory_from_usb /root/tempvoip voip
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/ cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf /root/tempvoip rm -rf /root/tempvoip
unmount_drive unmount_drive
exit 3679 exit 3679
fi fi
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf /root/tempvoip rm -rf /root/tempvoip
unmount_drive unmount_drive
exit 3679 exit 3679
fi fi
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/ cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf /root/tempvoip rm -rf /root/tempvoip
unmount_drive unmount_drive
exit 276 exit 276
fi fi
rm -rf /root/tempvoip rm -rf /root/tempvoip
cp /etc/ssl/certs/mumble* /var/lib/mumble-server cp /etc/ssl/certs/mumble* /var/lib/mumble-server
cp /etc/ssl/private/mumble* /var/lib/mumble-server cp /etc/ssl/private/mumble* /var/lib/mumble-server
chown -R mumble-server:mumble-server /var/lib/mumble-server chown -R mumble-server:mumble-server /var/lib/mumble-server
service sipwitch restart service sipwitch restart
service mumble-server restart service mumble-server restart
fi fi
} }
function restore_tox { function restore_tox {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'tox' ]]; then if [[ $RESTORE_APP != 'tox' ]]; then
return return
fi fi
fi fi
if [ -d $USB_MOUNT/backup/tox ]; then if [ -d $USB_MOUNT/backup/tox ]; then
echo $"Restoring Tox node settings" echo $"Restoring Tox node settings"
restore_directory_from_usb / tox restore_directory_from_usb / tox
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
unmount_drive unmount_drive
exit 6393 exit 6393
fi fi
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
systemctl restart tox-bootstrapd.service systemctl restart tox-bootstrapd.service
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
systemctl status tox-bootstrapd.service systemctl status tox-bootstrapd.service
unmount_drive unmount_drive
exit 59369 exit 59369
fi fi
fi fi
} }
function get_restore_app { function get_restore_app {
if [ ${1} ]; then if [ ${1} ]; then
if [ ! -d /home/${1} ]; then if [ ! -d /home/${1} ]; then
RESTORE_APP=${1} RESTORE_APP=${1}
echo $"Restore $RESTORE_APP" echo $"Restore $RESTORE_APP"
fi fi
fi fi
} }
get_restore_app ${2} get_restore_app ${2}

View File

@ -701,267 +701,267 @@ function restore_owncloud {
fi fi
if grep -q "Owncloud domain" $COMPLETION_FILE; then if grep -q "Owncloud domain" $COMPLETION_FILE; then
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}') 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" echo $"Restoring Owncloud installation"
cp -r /root/tempowncloudrepofiles/* / cp -r /root/tempowncloudfiles/* /
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 1458 exit 1458
fi fi
rm -rf /root/tempowncloudrepofiles rm -rf /root/tempowncloudfiles
fi fi
if [ -d $SERVER_DIRECTORY/backup/owncloudrepoconfig ]; then if [ -d $SERVER_DIRECTORY/backup/owncloudconfig ]; then
echo $"Restoring Owncloud installation" echo $"Restoring Owncloud installation"
cp -r /root/tempowncloudrepoconfig/* / cp -r /root/tempowncloudconfig/* /
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 2571 exit 2571
fi fi
rm -rf /root/tempowncloudrepoconfig rm -rf /root/tempowncloudconfig
fi 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 # re-index files
for d in /home/*/ ; do for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}') USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
/var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs/occ files:scan $USERNAME /var/www/owncloud/occ files:scan $USERNAME
fi fi
done done
fi fi
} }
function restore_gogs { function restore_gogs {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'gogs' ]]; then if [[ $RESTORE_APP != 'gogs' ]]; then
return return
fi fi
fi fi
if grep -q "Gogs domain" $COMPLETION_FILE; then if grep -q "Gogs domain" $COMPLETION_FILE; then
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}') GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
restore_database_from_friend gogs $GIT_DOMAIN_NAME restore_database_from_friend gogs $GIT_DOMAIN_NAME
if [ -d $SERVER_DIRECTORY/backup/gogs ]; then if [ -d $SERVER_DIRECTORY/backup/gogs ]; then
if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then
mkdir -p /home/git/go/src/github.com/gogits/gogs/custom mkdir -p /home/git/go/src/github.com/gogits/gogs/custom
fi fi
cp -r /root/tempgogs/home/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom/ 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 if [ ! "$?" = "0" ]; then
exit 5885 exit 5885
fi fi
echo $"Restoring Gogs repos" echo $"Restoring Gogs repos"
restore_directory_from_friend /root/tempgogsrepos gogsrepos restore_directory_from_friend /root/tempgogsrepos gogsrepos
cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/ cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 7649 exit 7649
fi fi
echo $"Restoring Gogs authorized_keys" echo $"Restoring Gogs authorized_keys"
restore_directory_from_friend /root/tempgogsssh gogsssh restore_directory_from_friend /root/tempgogsssh gogsssh
if [ ! -d /home/git/.ssh ]; then if [ ! -d /home/git/.ssh ]; then
mkdir /home/git/.ssh mkdir /home/git/.ssh
fi fi
cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/ cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 74239 exit 74239
fi fi
rm -rf /root/tempgogs rm -rf /root/tempgogs
rm -rf /root/tempgogsrepos rm -rf /root/tempgogsrepos
rm -rf /root/tempgogsssh rm -rf /root/tempgogsssh
chown -R git:git /home/git chown -R git:git /home/git
fi fi
fi fi
} }
function restore_wiki { function restore_wiki {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'wiki' ]]; then if [[ $RESTORE_APP != 'wiki' ]]; then
return return
fi fi
fi fi
if [ -d $SERVER_DIRECTORY/backup/wiki ]; then if [ -d $SERVER_DIRECTORY/backup/wiki ]; then
WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}') WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}')
echo $"Restoring Wiki installation $WIKI_DOMAIN_NAME" echo $"Restoring Wiki installation $WIKI_DOMAIN_NAME"
restore_directory_from_friend /root/tempwiki wiki restore_directory_from_friend /root/tempwiki wiki
cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/ cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 868 exit 868
fi fi
restore_directory_from_friend /root/tempwiki2 wiki2 restore_directory_from_friend /root/tempwiki2 wiki2
cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/ cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 869 exit 869
fi fi
rm -rf /root/tempwiki rm -rf /root/tempwiki
rm -rf /root/tempwiki2 rm -rf /root/tempwiki2
chown -R www-data:www-data /var/lib/dokuwiki/* chown -R www-data:www-data /var/lib/dokuwiki/*
# Ensure that the bundled SSL cert is being used # Ensure that the bundled SSL cert is being used
if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then 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} sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME}
fi fi
if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then 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}/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 ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem
fi fi
fi fi
} }
function restore_blog { function restore_blog {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'blog' ]]; then if [[ $RESTORE_APP != 'blog' ]]; then
return return
fi fi
fi fi
if [ -d $SERVER_DIRECTORY/backup/blog ]; then if [ -d $SERVER_DIRECTORY/backup/blog ]; then
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}') FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
echo $"Restoring blog installation $FULLBLOG_DOMAIN_NAME" echo $"Restoring blog installation $FULLBLOG_DOMAIN_NAME"
mkdir /root/tempblog mkdir /root/tempblog
restore_directory_from_friend /root/tempblog blog restore_directory_from_friend /root/tempblog blog
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/ cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 593 exit 593
fi fi
rm -rf /root/tempblog rm -rf /root/tempblog
if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
echo $"No content directory found after restoring blog" echo $"No content directory found after restoring blog"
exit 287 exit 287
fi fi
# Ensure that the bundled SSL cert is being used # Ensure that the bundled SSL cert is being used
if [ -f /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.bundle.crt ]; then 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} sed -i "s|${FULLBLOG_DOMAIN_NAME}.crt|${FULLBLOG_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${FULLBLOG_DOMAIN_NAME}
fi fi
for d in /home/*/ ; do for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}') USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; 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 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 done
if [ -d /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME} ]; then 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}/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 ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.pem
fi fi
fi fi
} }
function restore_cjdns { function restore_cjdns {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'cjdns' ]]; then if [[ $RESTORE_APP != 'cjdns' ]]; then
return return
fi fi
fi fi
if [ -d $SERVER_DIRECTORY/backup/cjdns ]; then if [ -d $SERVER_DIRECTORY/backup/cjdns ]; then
echo $"Restoring cjdns installation" echo $"Restoring cjdns installation"
restore_directory_from_friend /root/tempcjdns cjdns restore_directory_from_friend /root/tempcjdns cjdns
rm -rf /etc/cjdns rm -rf /etc/cjdns
cp -r /root/tempcjdns/etc/cjdns /etc/ cp -r /root/tempcjdns/etc/cjdns /etc/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 7438 exit 7438
fi fi
rm -rf /root/tempcjdns rm -rf /root/tempcjdns
fi fi
} }
function restore_voip { function restore_voip {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'voip' ]]; then if [[ $RESTORE_APP != 'voip' ]]; then
return return
fi fi
fi fi
if [ -d $SERVER_DIRECTORY/backup/voip ]; then if [ -d $SERVER_DIRECTORY/backup/voip ]; then
echo $"Restoring VoIP settings" echo $"Restoring VoIP settings"
restore_directory_from_friend /root/tempvoip voip restore_directory_from_friend /root/tempvoip voip
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/ cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf /root/tempvoip rm -rf /root/tempvoip
exit 7823 exit 7823
fi fi
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf /root/tempvoip rm -rf /root/tempvoip
exit 7823 exit 7823
fi fi
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/ cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf /root/tempvoip rm -rf /root/tempvoip
exit 276 exit 276
fi fi
rm -rf /root/tempvoip rm -rf /root/tempvoip
cp /etc/ssl/certs/mumble* /var/lib/mumble-server cp /etc/ssl/certs/mumble* /var/lib/mumble-server
cp /etc/ssl/private/mumble* /var/lib/mumble-server cp /etc/ssl/private/mumble* /var/lib/mumble-server
chown -R mumble-server:mumble-server /var/lib/mumble-server chown -R mumble-server:mumble-server /var/lib/mumble-server
service sipwitch restart service sipwitch restart
service mumble-server restart service mumble-server restart
fi fi
} }
function restore_tox { function restore_tox {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'tox' ]]; then if [[ $RESTORE_APP != 'tox' ]]; then
return return
fi fi
fi fi
if [ -d $SERVER_DIRECTORY/backup/tox ]; then if [ -d $SERVER_DIRECTORY/backup/tox ]; then
echo $"Restoring Tox node settings" echo $"Restoring Tox node settings"
restore_directory_from_friend / tox restore_directory_from_friend / tox
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 93653 exit 93653
fi fi
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
systemctl restart tox-bootstrapd.service systemctl restart tox-bootstrapd.service
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
systemctl status tox-bootstrapd.service systemctl status tox-bootstrapd.service
exit 59369 exit 59369
fi fi
fi fi
} }
function restore_email { function restore_email {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'email' ]]; then if [[ $RESTORE_APP != 'email' ]]; then
return return
fi fi
fi fi
for d in $SERVER_DIRECTORY/backup/mail/*/ ; do for d in $SERVER_DIRECTORY/backup/mail/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}') USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $SERVER_DIRECTORY/backup/mail/$USERNAME ]; then if [ -d $SERVER_DIRECTORY/backup/mail/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME ${PROJECT_NAME}-adduser $USERNAME
fi fi
echo $"Restoring emails for $USERNAME" echo $"Restoring emails for $USERNAME"
restore_directory_from_friend /root/tempmail mail/$USERNAME restore_directory_from_friend /root/tempmail mail/$USERNAME
if [ ! -d /home/$USERNAME/Maildir ]; then if [ ! -d /home/$USERNAME/Maildir ]; then
mkdir /home/$USERNAME/Maildir mkdir /home/$USERNAME/Maildir
fi fi
tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C / tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 927 exit 927
fi fi
rm -rf /root/tempmail rm -rf /root/tempmail
fi fi
fi fi
done done
} }
function restore_dlna { function restore_dlna {
if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'dlna' ]]; then if [[ $RESTORE_APP != 'dlna' ]]; then
return return
fi fi
fi fi
if [ -d /var/cache/minidlna ]; then if [ -d /var/cache/minidlna ]; then
if [ -d $SERVER_DIRECTORY/backup/dlna ]; then if [ -d $SERVER_DIRECTORY/backup/dlna ]; then
echo $"Restoring DLNA cache" echo $"Restoring DLNA cache"
restore_directory_from_friend /root/tempdlna dlna restore_directory_from_friend /root/tempdlna dlna
cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/ cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 982 exit 982
fi fi
rm -rf /root/tempdlna rm -rf /root/tempdlna
fi fi
fi fi
} }
# Social key management # Social key management

View File

@ -112,7 +112,7 @@ fi
if grep -q "install_owncloud_repo" $COMPLETION_FILE; then if grep -q "install_owncloud_repo" $COMPLETION_FILE; then
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}') 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 fi
userdel -r $MY_USERNAME userdel -r $MY_USERNAME