Add a tahoelafs introducer to the full install
This commit is contained in:
parent
e187ab9ce2
commit
3856005b72
|
@ -39,481 +39,481 @@ MY_BLOG_TITLE="My Blog"
|
|||
MY_BLOG_SUBTITLE="Another ${PROJECT_NAME} Blog"
|
||||
|
||||
function reconfigure_blog {
|
||||
echo -n ''
|
||||
echo -n ''
|
||||
}
|
||||
|
||||
function upgrade_blog {
|
||||
if ! grep -Fxq "install_blog" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
function_check set_repo_commit
|
||||
set_repo_commit /var/www/$FULLBLOG_DOMAIN_NAME/htdocs "Blog commit" "$FULLBLOG_COMMIT" $FULLBLOG_REPO
|
||||
if ! grep -Fxq "install_blog" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
function_check set_repo_commit
|
||||
set_repo_commit /var/www/$FULLBLOG_DOMAIN_NAME/htdocs "Blog commit" "$FULLBLOG_COMMIT" $FULLBLOG_REPO
|
||||
|
||||
# update blog avatar
|
||||
${PROJECT_NAME}-blog
|
||||
# update blog avatar
|
||||
${PROJECT_NAME}-blog
|
||||
}
|
||||
|
||||
function backup_local_blog {
|
||||
FULLBLOG_DOMAIN_NAME='blog'
|
||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
fi
|
||||
FULLBLOG_DOMAIN_NAME='blog'
|
||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
fi
|
||||
|
||||
source_directory=/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
if [ -d $source_directory ]; then
|
||||
dest_directory=blog
|
||||
echo $"Backing up $source_directory to $dest_directory"
|
||||
source_directory=/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
if [ -d $source_directory ]; then
|
||||
dest_directory=blog
|
||||
echo $"Backing up $source_directory to $dest_directory"
|
||||
|
||||
function_check suspend_site
|
||||
suspend_site ${FULLBLOG_DOMAIN_NAME}
|
||||
function_check suspend_site
|
||||
suspend_site ${FULLBLOG_DOMAIN_NAME}
|
||||
|
||||
function_check backup_directory_to_usb
|
||||
backup_directory_to_usb $source_directory $dest_directory
|
||||
function_check backup_directory_to_usb
|
||||
backup_directory_to_usb $source_directory $dest_directory
|
||||
|
||||
function_check restart_site
|
||||
restart_site
|
||||
function_check restart_site
|
||||
restart_site
|
||||
|
||||
echo $"Backup to $dest_directory complete"
|
||||
fi
|
||||
echo $"Backup to $dest_directory complete"
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_local_blog {
|
||||
FULLBLOG_DOMAIN_NAME='blog'
|
||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
fi
|
||||
if [ $FULLBLOG_DOMAIN_NAME ]; then
|
||||
echo $"Restoring blog installation"
|
||||
temp_restore_dir=/root/tempblog
|
||||
restore_directory_from_usb $temp_restore_dir blog
|
||||
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
cp -r $temp_restore_dir/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
set_user_permissions
|
||||
backup_unmount_drive
|
||||
exit 593
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
|
||||
echo $"No content directory found after restoring blog"
|
||||
set_user_permissions
|
||||
backup_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" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; 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
|
||||
FULLBLOG_DOMAIN_NAME='blog'
|
||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
fi
|
||||
if [ $FULLBLOG_DOMAIN_NAME ]; then
|
||||
echo $"Restoring blog installation"
|
||||
temp_restore_dir=/root/tempblog
|
||||
restore_directory_from_usb $temp_restore_dir blog
|
||||
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
cp -r $temp_restore_dir/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
set_user_permissions
|
||||
backup_unmount_drive
|
||||
exit 593
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
|
||||
echo $"No content directory found after restoring blog"
|
||||
set_user_permissions
|
||||
backup_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" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; 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 backup_remote_blog {
|
||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
temp_backup_dir=/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
if [ -d $temp_backup_dir ]; then
|
||||
echo $"Backing up blog"
|
||||
backup_directory_to_friend $temp_backup_dir blog
|
||||
echo $"Backup of blog complete"
|
||||
else
|
||||
echo $"Blog domain specified but not found in $temp_backup_dir"
|
||||
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}')
|
||||
temp_backup_dir=/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
if [ -d $temp_backup_dir ]; then
|
||||
echo $"Backing up blog"
|
||||
backup_directory_to_friend $temp_backup_dir blog
|
||||
echo $"Backup of blog complete"
|
||||
else
|
||||
echo $"Blog domain specified but not found in $temp_backup_dir"
|
||||
exit 2578
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_remote_blog {
|
||||
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"
|
||||
temp_restore_dir=/root/tempblog
|
||||
mkdir $temp_restore_dir
|
||||
function_check restore_directory_from_friend
|
||||
restore_directory_from_friend $temp_restore_dir blog
|
||||
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
cp -r $temp_restore_dir/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 593
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
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" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; 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
|
||||
echo $"Restore of blog complete"
|
||||
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"
|
||||
temp_restore_dir=/root/tempblog
|
||||
mkdir $temp_restore_dir
|
||||
function_check restore_directory_from_friend
|
||||
restore_directory_from_friend $temp_restore_dir blog
|
||||
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||
cp -r $temp_restore_dir/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 593
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
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" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; 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
|
||||
echo $"Restore of blog complete"
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_blog {
|
||||
if ! grep -Fxq "install_blog" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
if [ ! -d /var/www/$FULLBLOG_DOMAIN_NAME ]; then
|
||||
rm -rf /var/www/$FULLBLOG_DOMAIN_NAME
|
||||
fi
|
||||
nginx_dissite $FULLBLOG_DOMAIN_NAME
|
||||
if [ ! -f /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME ]; then
|
||||
rm -rf /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
fi
|
||||
if [ $FULLBLOG_CODE ]; then
|
||||
if [ -f /usr/bin/dynamicdns ]; then
|
||||
sed -i "/$FULLBLOG_DOMAIN_NAME/d" /usr/bin/dynamicdns
|
||||
sed -i "/$FULLBLOG_CODE/d" /usr/bin/dynamicdns
|
||||
fi
|
||||
fi
|
||||
function_check remove_onion_service
|
||||
remove_onion_service blog ${FULLBLOG_ONION_PORT}
|
||||
sed -i '/install_blog/d' $COMPLETION_FILE
|
||||
sed -i '/Blog .*/d' $COMPLETION_FILE
|
||||
if ! grep -Fxq "install_blog" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
if [ ! -d /var/www/$FULLBLOG_DOMAIN_NAME ]; then
|
||||
rm -rf /var/www/$FULLBLOG_DOMAIN_NAME
|
||||
fi
|
||||
nginx_dissite $FULLBLOG_DOMAIN_NAME
|
||||
if [ ! -f /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME ]; then
|
||||
rm -rf /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
fi
|
||||
if [ $FULLBLOG_CODE ]; then
|
||||
if [ -f /usr/bin/dynamicdns ]; then
|
||||
sed -i "/$FULLBLOG_DOMAIN_NAME/d" /usr/bin/dynamicdns
|
||||
sed -i "/$FULLBLOG_CODE/d" /usr/bin/dynamicdns
|
||||
fi
|
||||
fi
|
||||
function_check remove_onion_service
|
||||
remove_onion_service blog ${FULLBLOG_ONION_PORT}
|
||||
sed -i '/install_blog/d' $COMPLETION_FILE
|
||||
sed -i '/Blog .*/d' $COMPLETION_FILE
|
||||
}
|
||||
|
||||
function get_blog_admin_password {
|
||||
if [ -f /home/$MY_USERNAME/README ]; then
|
||||
if grep -q "Your blog password is" /home/$MY_USERNAME/README; then
|
||||
FULLBLOG_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Your blog password is" | awk -F ':' '{print $2}' | sed 's/^ *//')
|
||||
fi
|
||||
fi
|
||||
if [ -f /home/$MY_USERNAME/README ]; then
|
||||
if grep -q "Your blog password is" /home/$MY_USERNAME/README; then
|
||||
FULLBLOG_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Your blog password is" | awk -F ':' '{print $2}' | sed 's/^ *//')
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function install_blog_social_networks {
|
||||
# set social networks
|
||||
if grep -q "social.hubzilla" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini; then
|
||||
sed -i "s|;social.hubzilla|social.hubzilla|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|social.hubzilla.*|social.hubzilla = \"$HUBZILLA_DOMAIN_NAME\"|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
fi
|
||||
if grep -q "social.gnusocial" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini; then
|
||||
sed -i "s|;social.gnusocial|social.gnusocial|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|social.gnusocial.*|social.gnusocial = \"$MICROBLOG_DOMAIN_NAME\"|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
fi
|
||||
# set social networks
|
||||
if grep -q "social.hubzilla" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini; then
|
||||
sed -i "s|;social.hubzilla|social.hubzilla|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|social.hubzilla.*|social.hubzilla = \"$HUBZILLA_DOMAIN_NAME\"|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
fi
|
||||
if grep -q "social.gnusocial" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini; then
|
||||
sed -i "s|;social.gnusocial|social.gnusocial|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|social.gnusocial.*|social.gnusocial = \"$MICROBLOG_DOMAIN_NAME\"|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
fi
|
||||
|
||||
# clear proprietary social network strings
|
||||
sed -i 's|social.facebook.*|social.facebook = ""|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i 's|social.twitter.*|social.twitter = ""|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i 's|social.google.*|social.google = ""|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
# clear proprietary social network strings
|
||||
sed -i 's|social.facebook.*|social.facebook = ""|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i 's|social.twitter.*|social.twitter = ""|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i 's|social.google.*|social.google = ""|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
}
|
||||
|
||||
function install_blog_user {
|
||||
# create a user password
|
||||
function_check get_blog_admin_password
|
||||
get_blog_admin_password
|
||||
if [ ! $FULLBLOG_ADMIN_PASSWORD ]; then
|
||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
FULLBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
FULLBLOG_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
||||
fi
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
echo $'HTMLy Blog' >> /home/$MY_USERNAME/README
|
||||
echo '==========' >> /home/$MY_USERNAME/README
|
||||
echo $"Your blog username: $MY_USERNAME" >> /home/$MY_USERNAME/README
|
||||
echo $"Your blog password is: $FULLBLOG_ADMIN_PASSWORD" >> /home/$MY_USERNAME/README
|
||||
if [[ $ONION_ONLY == 'no' ]]; then
|
||||
echo $"Log into your blog at https://$FULLBLOG_DOMAIN_NAME/login" >> /home/$MY_USERNAME/README
|
||||
fi
|
||||
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
|
||||
chmod 600 /home/$MY_USERNAME/README
|
||||
fi
|
||||
# create a user password
|
||||
function_check get_blog_admin_password
|
||||
get_blog_admin_password
|
||||
if [ ! $FULLBLOG_ADMIN_PASSWORD ]; then
|
||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
||||
FULLBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
||||
else
|
||||
FULLBLOG_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
||||
fi
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
echo $'HTMLy Blog' >> /home/$MY_USERNAME/README
|
||||
echo '==========' >> /home/$MY_USERNAME/README
|
||||
echo $"Your blog username: $MY_USERNAME" >> /home/$MY_USERNAME/README
|
||||
echo $"Your blog password is: $FULLBLOG_ADMIN_PASSWORD" >> /home/$MY_USERNAME/README
|
||||
if [[ $ONION_ONLY == 'no' ]]; then
|
||||
echo $"Log into your blog at https://$FULLBLOG_DOMAIN_NAME/login" >> /home/$MY_USERNAME/README
|
||||
fi
|
||||
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
|
||||
chmod 600 /home/$MY_USERNAME/README
|
||||
fi
|
||||
|
||||
# create a user
|
||||
FULLBLOG_ADMIN_PASSWORD_HASH=$(${PROJECT_NAME}-sec --bloghash "$FULLBLOG_ADMIN_PASSWORD")
|
||||
if [ ${#FULLBLOG_ADMIN_PASSWORD_HASH} -lt 8 ]; then
|
||||
echo $'Blog admin password could not be hashed'
|
||||
exit 625728
|
||||
fi
|
||||
echo ';Password' > /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo "password = $FULLBLOG_ADMIN_PASSWORD_HASH" >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo 'encryption = password_hash' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo ';Role' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo 'role = admin' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
# create a user
|
||||
FULLBLOG_ADMIN_PASSWORD_HASH=$(${PROJECT_NAME}-sec --bloghash "$FULLBLOG_ADMIN_PASSWORD")
|
||||
if [ ${#FULLBLOG_ADMIN_PASSWORD_HASH} -lt 8 ]; then
|
||||
echo $'Blog admin password could not be hashed'
|
||||
exit 625728
|
||||
fi
|
||||
echo ';Password' > /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo "password = $FULLBLOG_ADMIN_PASSWORD_HASH" >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo 'encryption = password_hash' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo ';Role' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo 'role = admin' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
}
|
||||
|
||||
function install_blog_settings {
|
||||
cp /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini.example /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|site.url.*|site.url = '/'|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|blog.title.*|blog.title = '$MY_BLOG_TITLE'|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|blog.tagline.*|blog.tagline = '$MY_BLOG_SUBTITLE'|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i 's|timezone.*|timezone = "Europe/London"|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|Your name|$MY_NAME|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
cp /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini.example /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|site.url.*|site.url = '/'|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|blog.title.*|blog.title = '$MY_BLOG_TITLE'|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|blog.tagline.*|blog.tagline = '$MY_BLOG_SUBTITLE'|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i 's|timezone.*|timezone = "Europe/London"|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
sed -i "s|Your name|$MY_NAME|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
|
||||
}
|
||||
|
||||
function install_blog_website {
|
||||
function_check nginx_http_redirect
|
||||
nginx_http_redirect $FULLBLOG_DOMAIN_NAME
|
||||
echo 'server {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' listen 443 ssl;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " root /var/www/$FULLBLOG_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " server_name $FULLBLOG_DOMAIN_NAME;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' access_log off;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " error_log /var/log/nginx/${FULLBLOG_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' charset utf-8;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_limits
|
||||
nginx_limits $FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_ssl
|
||||
nginx_ssl $FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_disable_sniffing
|
||||
nginx_disable_sniffing $FULLBLOG_DOMAIN_NAME
|
||||
echo ' add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location / {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' allow all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # statically serve these file types when possible' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # otherwise fall back to front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # allow browser to cache them' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' expires 30d;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # block these file types' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # or a unix socket' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.php$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # Zero-day exploit defense.' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # With php5-cgi alone:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # With php5-fpm:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' include fastcgi_params;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /\. {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' #deny access to store' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /store {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '}' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_http_redirect
|
||||
nginx_http_redirect $FULLBLOG_DOMAIN_NAME
|
||||
echo 'server {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' listen 443 ssl;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " root /var/www/$FULLBLOG_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " server_name $FULLBLOG_DOMAIN_NAME;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' access_log off;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " error_log /var/log/nginx/${FULLBLOG_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' charset utf-8;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_limits
|
||||
nginx_limits $FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_ssl
|
||||
nginx_ssl $FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_disable_sniffing
|
||||
nginx_disable_sniffing $FULLBLOG_DOMAIN_NAME
|
||||
echo ' add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location / {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' allow all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # statically serve these file types when possible' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # otherwise fall back to front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # allow browser to cache them' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' expires 30d;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # block these file types' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # or a unix socket' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.php$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # Zero-day exploit defense.' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # With php5-cgi alone:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # With php5-fpm:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' include fastcgi_params;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /\. {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' #deny access to store' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /store {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '}' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
}
|
||||
|
||||
function install_blog_website_onion {
|
||||
echo 'server {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " listen 127.0.0.1:${FULLBLOG_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " root /var/www/$FULLBLOG_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " server_name $FULLBLOG_DOMAIN_NAME;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' access_log off;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " error_log /var/log/nginx/${FULLBLOG_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' charset utf-8;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_limits
|
||||
nginx_limits $FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_disable_sniffing
|
||||
nginx_disable_sniffing $FULLBLOG_DOMAIN_NAME
|
||||
echo ' add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location / {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' allow all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # statically serve these file types when possible' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # otherwise fall back to front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # allow browser to cache them' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' expires 30d;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # block these file types' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # or a unix socket' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.php$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # Zero-day exploit defense.' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # With php5-cgi alone:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # With php5-fpm:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' include fastcgi_params;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /\. {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' #deny access to store' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /store {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '}' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo 'server {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " listen 127.0.0.1:${FULLBLOG_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " root /var/www/$FULLBLOG_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " server_name $FULLBLOG_DOMAIN_NAME;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' access_log off;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " error_log /var/log/nginx/${FULLBLOG_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' charset utf-8;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_limits
|
||||
nginx_limits $FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_disable_sniffing
|
||||
nginx_disable_sniffing $FULLBLOG_DOMAIN_NAME
|
||||
echo ' add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location / {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' allow all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # statically serve these file types when possible' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # otherwise fall back to front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # allow browser to cache them' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' expires 30d;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # block these file types' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # or a unix socket' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~* \.php$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # Zero-day exploit defense.' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo " # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # With php5-cgi alone:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # With php5-fpm:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' include fastcgi_params;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /\. {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' #deny access to store' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /store {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo ' }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
echo '}' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
}
|
||||
|
||||
function install_blog_from_repo {
|
||||
if [ ! -d /var/www/$FULLBLOG_DOMAIN_NAME ]; then
|
||||
mkdir /var/www/$FULLBLOG_DOMAIN_NAME
|
||||
fi
|
||||
if [ ! -d /var/www/$FULLBLOG_DOMAIN_NAME ]; then
|
||||
mkdir /var/www/$FULLBLOG_DOMAIN_NAME
|
||||
fi
|
||||
|
||||
cd /var/www/$FULLBLOG_DOMAIN_NAME
|
||||
git_clone $FULLBLOG_REPO htdocs
|
||||
cd htdocs
|
||||
git checkout $FULLBLOG_COMMIT -b $FULLBLOG_COMMIT
|
||||
if ! grep -q "Blog commit" $COMPLETION_FILE; then
|
||||
echo "Blog commit:$FULLBLOG_COMMIT" >> $COMPLETION_FILE
|
||||
else
|
||||
sed -i "s/Blog commit.*/Blog commit:$FULLBLOG_COMMIT/g" $COMPLETION_FILE
|
||||
fi
|
||||
cd /var/www/$FULLBLOG_DOMAIN_NAME
|
||||
git_clone $FULLBLOG_REPO htdocs
|
||||
cd htdocs
|
||||
git checkout $FULLBLOG_COMMIT -b $FULLBLOG_COMMIT
|
||||
if ! grep -q "Blog commit" $COMPLETION_FILE; then
|
||||
echo "Blog commit:$FULLBLOG_COMMIT" >> $COMPLETION_FILE
|
||||
else
|
||||
sed -i "s/Blog commit.*/Blog commit:$FULLBLOG_COMMIT/g" $COMPLETION_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
function install_blog {
|
||||
if [ ! $FULLBLOG_DOMAIN_NAME ]; then
|
||||
echo $'The blog domain name was not specified'
|
||||
exit 5062
|
||||
fi
|
||||
if [ ! $FULLBLOG_DOMAIN_NAME ]; then
|
||||
echo $'The blog domain name was not specified'
|
||||
exit 5062
|
||||
fi
|
||||
|
||||
if grep -Fxq "install_blog" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
if grep -Fxq "install_blog" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
|
||||
# for the avatar changing command
|
||||
apt-get -y install imagemagick
|
||||
# for the avatar changing command
|
||||
apt-get -y install imagemagick
|
||||
|
||||
function_check install_blog_from_repo
|
||||
install_blog_from_repo
|
||||
function_check install_blog_from_repo
|
||||
install_blog_from_repo
|
||||
|
||||
if [[ $ONION_ONLY == "no" ]]; then
|
||||
function_check install_blog_website
|
||||
install_blog_website
|
||||
else
|
||||
echo -n '' > /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
fi
|
||||
function_check install_blog_website_onion
|
||||
install_blog_website_onion
|
||||
if [[ $ONION_ONLY == "no" ]]; then
|
||||
function_check install_blog_website
|
||||
install_blog_website
|
||||
else
|
||||
echo -n '' > /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
fi
|
||||
function_check install_blog_website_onion
|
||||
install_blog_website_onion
|
||||
|
||||
function_check create_site_certificate
|
||||
create_site_certificate $FULLBLOG_DOMAIN_NAME 'yes'
|
||||
function_check create_site_certificate
|
||||
create_site_certificate $FULLBLOG_DOMAIN_NAME 'yes'
|
||||
|
||||
function_check configure_php
|
||||
configure_php
|
||||
function_check configure_php
|
||||
configure_php
|
||||
|
||||
function_check install_blog_settings
|
||||
install_blog_settings
|
||||
function_check install_blog_settings
|
||||
install_blog_settings
|
||||
|
||||
function_check install_blog_social_networks
|
||||
install_blog_social_networks
|
||||
function_check install_blog_social_networks
|
||||
install_blog_social_networks
|
||||
|
||||
function_check install_blog_user
|
||||
install_blog_user
|
||||
function_check install_blog_user
|
||||
install_blog_user
|
||||
|
||||
chown -R www-data:www-data /var/www/$FULLBLOG_DOMAIN_NAME/htdocs
|
||||
chown -R www-data:www-data /var/www/$FULLBLOG_DOMAIN_NAME/htdocs
|
||||
|
||||
FULLBLOG_ONION_HOSTNAME=$(add_onion_service blog 80 ${FULLBLOG_ONION_PORT})
|
||||
FULLBLOG_ONION_HOSTNAME=$(add_onion_service blog 80 ${FULLBLOG_ONION_PORT})
|
||||
|
||||
function_check nginx_ensite
|
||||
nginx_ensite $FULLBLOG_DOMAIN_NAME
|
||||
function_check nginx_ensite
|
||||
nginx_ensite $FULLBLOG_DOMAIN_NAME
|
||||
|
||||
systemctl restart php5-fpm
|
||||
systemctl restart nginx
|
||||
systemctl restart php5-fpm
|
||||
systemctl restart nginx
|
||||
|
||||
if ! grep -q "Blog onion domain" /home/$MY_USERNAME/README; then
|
||||
echo $"Blog onion domain: ${FULLBLOG_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
|
||||
echo $"Log into your blog at https://${FULLBLOG_ONION_HOSTNAME}/login" >> /home/$MY_USERNAME/README
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
|
||||
chmod 600 /home/$MY_USERNAME/README
|
||||
fi
|
||||
echo "Blog onion domain:${FULLBLOG_ONION_HOSTNAME}" >> $COMPLETION_FILE
|
||||
if ! grep -q "Blog onion domain" /home/$MY_USERNAME/README; then
|
||||
echo $"Blog onion domain: ${FULLBLOG_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
|
||||
echo $"Log into your blog at https://${FULLBLOG_ONION_HOSTNAME}/login" >> /home/$MY_USERNAME/README
|
||||
echo '' >> /home/$MY_USERNAME/README
|
||||
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
|
||||
chmod 600 /home/$MY_USERNAME/README
|
||||
fi
|
||||
echo "Blog onion domain:${FULLBLOG_ONION_HOSTNAME}" >> $COMPLETION_FILE
|
||||
|
||||
function_check add_ddns_domain
|
||||
add_ddns_domain $FULLBLOG_DOMAIN_NAME
|
||||
function_check add_ddns_domain
|
||||
add_ddns_domain $FULLBLOG_DOMAIN_NAME
|
||||
|
||||
if ! grep -q "Blog domain:" $COMPLETION_FILE; then
|
||||
echo "Blog domain:$FULLBLOG_DOMAIN_NAME" >> $COMPLETION_FILE
|
||||
fi
|
||||
if ! grep -q "Blog domain:" $COMPLETION_FILE; then
|
||||
echo "Blog domain:$FULLBLOG_DOMAIN_NAME" >> $COMPLETION_FILE
|
||||
fi
|
||||
|
||||
echo 'install_blog' >> $COMPLETION_FILE
|
||||
echo 'install_blog' >> $COMPLETION_FILE
|
||||
}
|
||||
|
||||
# NOTE: deliberately no exit 0
|
||||
|
|
|
@ -31,154 +31,154 @@
|
|||
VARIANTS='all'
|
||||
|
||||
function reconfigure_emacs {
|
||||
echo -n ''
|
||||
echo -n ''
|
||||
}
|
||||
|
||||
function upgrade_emacs {
|
||||
echo -n ''
|
||||
echo -n ''
|
||||
}
|
||||
|
||||
function backup_local_emacs {
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [ -d /home/$USERNAME/.emacs.d ]; then
|
||||
echo $"Backing up Emacs config for $USERNAME"
|
||||
if [ -f /home/$USERNAME/.emacs ]; then
|
||||
cp /home/$USERNAME/.emacs /home/$USERNAME/.emacs.d/dotemacs
|
||||
fi
|
||||
function_check backup_directory_to_usb
|
||||
backup_directory_to_usb /home/$USERNAME/.emacs.d config/$USERNAME
|
||||
fi
|
||||
fi
|
||||
done
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d /home/$USERNAME/.emacs.d ]; then
|
||||
echo $"Backing up Emacs config for $USERNAME"
|
||||
if [ -f /home/$USERNAME/.emacs ]; then
|
||||
cp /home/$USERNAME/.emacs /home/$USERNAME/.emacs.d/dotemacs
|
||||
fi
|
||||
function_check backup_directory_to_usb
|
||||
backup_directory_to_usb /home/$USERNAME/.emacs.d config/$USERNAME
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function restore_local_emacs {
|
||||
temp_restore_dir=/root/tempemacs
|
||||
if [ -d $USB_MOUNT/backup/emacs ]; then
|
||||
for d in $USB_MOUNT/backup/emacs/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
echo $"Restoring Emacs config for $USERNAME"
|
||||
function_check restore_directory_from_usb
|
||||
restore_directory_from_usb $temp_restore_dir emacs/$USERNAME
|
||||
cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf $temp_restore_dir
|
||||
function_check set_user_permissions
|
||||
set_user_permissions
|
||||
function_check backup_unmount_drive
|
||||
backup_unmount_drive
|
||||
exit 664
|
||||
fi
|
||||
cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
|
||||
rm -rf $temp_restore_dir
|
||||
fi
|
||||
done
|
||||
fi
|
||||
temp_restore_dir=/root/tempemacs
|
||||
if [ -d $USB_MOUNT/backup/emacs ]; then
|
||||
for d in $USB_MOUNT/backup/emacs/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
echo $"Restoring Emacs config for $USERNAME"
|
||||
function_check restore_directory_from_usb
|
||||
restore_directory_from_usb $temp_restore_dir emacs/$USERNAME
|
||||
cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf $temp_restore_dir
|
||||
function_check set_user_permissions
|
||||
set_user_permissions
|
||||
function_check backup_unmount_drive
|
||||
backup_unmount_drive
|
||||
exit 664
|
||||
fi
|
||||
cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
|
||||
rm -rf $temp_restore_dir
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_remote_emacs {
|
||||
echo -n ''
|
||||
echo -n ''
|
||||
}
|
||||
|
||||
function restore_remote_emacs {
|
||||
echo -n ''
|
||||
echo -n ''
|
||||
}
|
||||
|
||||
function remove_emacs {
|
||||
if ! grep -Fxq "install_emacs" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
apt-get -y remove --purge emacs24
|
||||
update-alternatives --set editor /usr/bin/nano
|
||||
sed -i '/install_emacs/d' $COMPLETION_FILE
|
||||
if ! grep -Fxq "install_emacs" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
apt-get -y remove --purge emacs24
|
||||
update-alternatives --set editor /usr/bin/nano
|
||||
sed -i '/install_emacs/d' $COMPLETION_FILE
|
||||
}
|
||||
|
||||
function install_emacs {
|
||||
if grep -Fxq "install_emacs" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
update-alternatives --set editor /usr/bin/emacs24
|
||||
if grep -Fxq "install_emacs" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
update-alternatives --set editor /usr/bin/emacs24
|
||||
|
||||
# A minimal emacs configuration
|
||||
#echo -n "(add-to-list 'load-path " > /home/$MY_USERNAME/.emacs
|
||||
#echo '"~/.emacs.d/")' >> /home/$MY_USERNAME/.emacs
|
||||
#echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Remove trailing whitepace ======================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo ";;(add-hook 'before-save-hook 'delete-trailing-whitespace)" >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; Goto a line number with CTRL-l' >> /home/$MY_USERNAME/.emacs
|
||||
echo -n '(global-set-key "\C-l" ' >> /home/$MY_USERNAME/.emacs
|
||||
echo "'goto-line)" >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Show line numbers ==============================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo "(add-hook 'find-file-hook (lambda () (linum-mode 1)))" >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Enable line wrapping in org-mode ===============================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo " (add-hook 'org-mode-hook" >> /home/$MY_USERNAME/.emacs
|
||||
echo " '(lambda ()" >> /home/$MY_USERNAME/.emacs
|
||||
echo " (visual-line-mode 1)))" >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Enable shift select in org mode ================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq org-support-shift-select t)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Set standard indent to 4 rather that 4 =========================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq standard-indent 4)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq-default tab-width 4)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq c-basic-offset 4)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Support Wheel Mouse Scrolling ==================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(mouse-wheel-mode t)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Place Backup Files in Specific Directory =======================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq make-backup-files t)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq version-control t)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Make Text mode the default mode for new buffers ================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo "(setq default-major-mode 'text-mode)" >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Line length ====================================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq-default fill-column 72)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Enable Line and Column Numbering ===============================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(line-number-mode 1)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(column-number-mode 1)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Turn on Auto Fill mode automatically in all modes ==============' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; Auto-fill-mode the the automatic wrapping of lines and insertion of' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; newlines when the cursor goes over the column limit.' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; This should actually turn on auto-fill-mode by default in all major' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; modes. The other way to do this is to turn on the fill for specific modes' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; via hooks.' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq auto-fill-mode 1)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Enable GPG encryption =========================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo "(require 'epa)" >> /home/$MY_USERNAME/.emacs
|
||||
echo '(epa-file-enable)' >> /home/$MY_USERNAME/.emacs
|
||||
cp /home/$MY_USERNAME/.emacs /root/.emacs
|
||||
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.emacs
|
||||
# A minimal emacs configuration
|
||||
#echo -n "(add-to-list 'load-path " > /home/$MY_USERNAME/.emacs
|
||||
#echo '"~/.emacs.d/")' >> /home/$MY_USERNAME/.emacs
|
||||
#echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Remove trailing whitepace ======================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo ";;(add-hook 'before-save-hook 'delete-trailing-whitespace)" >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; Goto a line number with CTRL-l' >> /home/$MY_USERNAME/.emacs
|
||||
echo -n '(global-set-key "\C-l" ' >> /home/$MY_USERNAME/.emacs
|
||||
echo "'goto-line)" >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Show line numbers ==============================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo "(add-hook 'find-file-hook (lambda () (linum-mode 1)))" >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Enable line wrapping in org-mode ===============================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo " (add-hook 'org-mode-hook" >> /home/$MY_USERNAME/.emacs
|
||||
echo " '(lambda ()" >> /home/$MY_USERNAME/.emacs
|
||||
echo " (visual-line-mode 1)))" >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Enable shift select in org mode ================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq org-support-shift-select t)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Set standard indent to 4 rather that 4 =========================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq standard-indent 4)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq-default tab-width 4)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq c-basic-offset 4)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Support Wheel Mouse Scrolling ==================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(mouse-wheel-mode t)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Place Backup Files in Specific Directory =======================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq make-backup-files t)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq version-control t)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Make Text mode the default mode for new buffers ================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo "(setq default-major-mode 'text-mode)" >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Line length ====================================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq-default fill-column 72)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Enable Line and Column Numbering ===============================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(line-number-mode 1)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(column-number-mode 1)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Turn on Auto Fill mode automatically in all modes ==============' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; Auto-fill-mode the the automatic wrapping of lines and insertion of' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; newlines when the cursor goes over the column limit.' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; This should actually turn on auto-fill-mode by default in all major' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; modes. The other way to do this is to turn on the fill for specific modes' >> /home/$MY_USERNAME/.emacs
|
||||
echo ';; via hooks.' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo '(setq auto-fill-mode 1)' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo $';; ===== Enable GPG encryption =========================================' >> /home/$MY_USERNAME/.emacs
|
||||
echo '' >> /home/$MY_USERNAME/.emacs
|
||||
echo "(require 'epa)" >> /home/$MY_USERNAME/.emacs
|
||||
echo '(epa-file-enable)' >> /home/$MY_USERNAME/.emacs
|
||||
cp /home/$MY_USERNAME/.emacs /root/.emacs
|
||||
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.emacs
|
||||
|
||||
echo 'install_emacs' >> $COMPLETION_FILE
|
||||
echo 'install_emacs' >> $COMPLETION_FILE
|
||||
}
|
||||
|
||||
# NOTE: deliberately no exit 0
|
||||
|
|
|
@ -40,295 +40,295 @@ SYNCTHING_SHARED_DATA=/var/lib/syncthing/SyncShared
|
|||
SYNCTHING_USER_IDS_FILE='.syncthingids'
|
||||
|
||||
function reconfigure_syncthing {
|
||||
echo -n ''
|
||||
echo -n ''
|
||||
}
|
||||
|
||||
function upgrade_syncthing {
|
||||
echo -n ''
|
||||
echo -n ''
|
||||
}
|
||||
|
||||
function backup_local_syncthing {
|
||||
if [ -d /var/lib/syncthing/SyncShared ]; then
|
||||
echo $"Backing up syncthing"
|
||||
if [ -d /var/lib/syncthing/SyncShared ]; then
|
||||
echo $"Backing up syncthing"
|
||||
|
||||
function_check backup_directory_to_usb
|
||||
backup_directory_to_usb /var/lib/syncthing/SyncShared syncthingshared
|
||||
backup_directory_to_usb /root/.config/syncthing syncthingconfig
|
||||
function_check backup_directory_to_usb
|
||||
backup_directory_to_usb /var/lib/syncthing/SyncShared syncthingshared
|
||||
backup_directory_to_usb /root/.config/syncthing syncthingconfig
|
||||
|
||||
echo $"Backup to syncthing complete"
|
||||
fi
|
||||
echo $"Backup to syncthing complete"
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_local_syncthing {
|
||||
if [ -f /etc/systemd/system/syncthing.service ]; then
|
||||
systemctl stop syncthing
|
||||
systemctl stop cron
|
||||
fi
|
||||
if [ -f /etc/systemd/system/syncthing.service ]; then
|
||||
systemctl stop syncthing
|
||||
systemctl stop cron
|
||||
fi
|
||||
|
||||
temp_restore_dir=/root/tempsyncthing
|
||||
if [ -d $USB_MOUNT/backup/syncthingconfig ]; then
|
||||
echo $"Restoring syncthing configuration"
|
||||
function_check restore_directory_from_usb
|
||||
restore_directory_from_usb ${temp_restore_dir}config syncthingconfig
|
||||
cp -r ${temp_restore_dir}config/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
set_user_permissions
|
||||
backup_unmount_drive
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 6833
|
||||
fi
|
||||
rm -rf ${temp_restore_dir}config
|
||||
fi
|
||||
temp_restore_dir=/root/tempsyncthing
|
||||
if [ -d $USB_MOUNT/backup/syncthingconfig ]; then
|
||||
echo $"Restoring syncthing configuration"
|
||||
function_check restore_directory_from_usb
|
||||
restore_directory_from_usb ${temp_restore_dir}config syncthingconfig
|
||||
cp -r ${temp_restore_dir}config/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
set_user_permissions
|
||||
backup_unmount_drive
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 6833
|
||||
fi
|
||||
rm -rf ${temp_restore_dir}config
|
||||
fi
|
||||
|
||||
if [ -d $USB_MOUNT/backup/syncthingshared ]; then
|
||||
echo $"Restoring syncthing shared files"
|
||||
restore_directory_from_usb ${temp_restore_dir}shared syncthingshared
|
||||
cp -r ${temp_restore_dir}shared/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
set_user_permissions
|
||||
backup_unmount_drive
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 37904
|
||||
fi
|
||||
rm -rf ${temp_restore_dir}shared
|
||||
fi
|
||||
if [ -d $USB_MOUNT/backup/syncthingshared ]; then
|
||||
echo $"Restoring syncthing shared files"
|
||||
restore_directory_from_usb ${temp_restore_dir}shared syncthingshared
|
||||
cp -r ${temp_restore_dir}shared/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
set_user_permissions
|
||||
backup_unmount_drive
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 37904
|
||||
fi
|
||||
rm -rf ${temp_restore_dir}shared
|
||||
fi
|
||||
|
||||
if [ -d $USB_MOUNT/backup/syncthing ]; then
|
||||
for d in $USB_MOUNT/backup/syncthing/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
echo $"Restoring syncthing files for $USERNAME"
|
||||
restore_directory_from_usb ${temp_restore_dir} syncthing/$USERNAME
|
||||
cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf ${temp_restore_dir}
|
||||
set_user_permissions
|
||||
backup_unmount_drive
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 68438
|
||||
fi
|
||||
rm -rf ${temp_restore_dir}
|
||||
if [ -d $USB_MOUNT/backup/syncthing ]; then
|
||||
for d in $USB_MOUNT/backup/syncthing/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
echo $"Restoring syncthing files for $USERNAME"
|
||||
restore_directory_from_usb ${temp_restore_dir} syncthing/$USERNAME
|
||||
cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf ${temp_restore_dir}
|
||||
set_user_permissions
|
||||
backup_unmount_drive
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 68438
|
||||
fi
|
||||
rm -rf ${temp_restore_dir}
|
||||
|
||||
# restore device IDs from config settings
|
||||
if [ -f /home/$USERNAME/.config/syncthing/.syncthing-server-id ]; then
|
||||
cp /home/$USERNAME/.config/syncthing/.syncthing-server-id /home/$USERNAME/.syncthing-server-id
|
||||
chown $USERNAME:$USERNAME /home/$USERNAME/.syncthing-server-id
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.config/syncthing/.syncthingids ]; then
|
||||
cp /home/$USERNAME/.config/syncthing/.syncthingids /home/$USERNAME/.syncthingids
|
||||
chown $USERNAME:$USERNAME /home/$USERNAME/.syncthingids
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# restore device IDs from config settings
|
||||
if [ -f /home/$USERNAME/.config/syncthing/.syncthing-server-id ]; then
|
||||
cp /home/$USERNAME/.config/syncthing/.syncthing-server-id /home/$USERNAME/.syncthing-server-id
|
||||
chown $USERNAME:$USERNAME /home/$USERNAME/.syncthing-server-id
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.config/syncthing/.syncthingids ]; then
|
||||
cp /home/$USERNAME/.config/syncthing/.syncthingids /home/$USERNAME/.syncthingids
|
||||
chown $USERNAME:$USERNAME /home/$USERNAME/.syncthingids
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -f /etc/systemd/system/syncthing.service ]; then
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
fi
|
||||
if [ -f /etc/systemd/system/syncthing.service ]; then
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_remote_syncthing {
|
||||
if [ -d /root/.config/syncthing ]; then
|
||||
echo $"Backing up syncthing configuration"
|
||||
function_check backup_directory_to_friend
|
||||
backup_directory_to_friend /root/.config/syncthing syncthingconfig
|
||||
echo $"Backup of syncthing configuration complete"
|
||||
fi
|
||||
if [ -d /var/lib/syncthing/SyncShared ]; then
|
||||
echo $"Backing up syncthing shared files"
|
||||
function_check backup_directory_to_friend
|
||||
backup_directory_to_friend /var/lib/syncthing/SyncShared syncthingshared
|
||||
echo $"Backup of syncthing shared files complete"
|
||||
fi
|
||||
if [ -d /root/.config/syncthing ]; then
|
||||
echo $"Backing up syncthing configuration"
|
||||
function_check backup_directory_to_friend
|
||||
backup_directory_to_friend /root/.config/syncthing syncthingconfig
|
||||
echo $"Backup of syncthing configuration complete"
|
||||
fi
|
||||
if [ -d /var/lib/syncthing/SyncShared ]; then
|
||||
echo $"Backing up syncthing shared files"
|
||||
function_check backup_directory_to_friend
|
||||
backup_directory_to_friend /var/lib/syncthing/SyncShared syncthingshared
|
||||
echo $"Backup of syncthing shared files complete"
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_remote_syncthing {
|
||||
if [ -f /etc/systemd/system/syncthing.service ]; then
|
||||
systemctl stop syncthing
|
||||
systemctl stop cron
|
||||
fi
|
||||
if [ -f /etc/systemd/system/syncthing.service ]; then
|
||||
systemctl stop syncthing
|
||||
systemctl stop cron
|
||||
fi
|
||||
|
||||
if [ -d $SERVER_DIRECTORY/backup/syncthingconfig ]; then
|
||||
echo $"Restoring syncthing configuration"
|
||||
temp_restore_dir=/root/tempsyncthingconfig
|
||||
function_check restore_directory_from_friend
|
||||
restore_directory_from_friend $temp_restore_dir syncthingconfig
|
||||
cp -r $temp_restore_dir/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 6833
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/syncthingconfig ]; then
|
||||
echo $"Restoring syncthing configuration"
|
||||
temp_restore_dir=/root/tempsyncthingconfig
|
||||
function_check restore_directory_from_friend
|
||||
restore_directory_from_friend $temp_restore_dir syncthingconfig
|
||||
cp -r $temp_restore_dir/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 6833
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
fi
|
||||
|
||||
if [ -d $SERVER_DIRECTORY/backup/syncthingshared ]; then
|
||||
echo $"Restoring syncthing shared files"
|
||||
temp_restore_dir=/root/tempsyncthingshared
|
||||
function_check restore_directory_from_friend
|
||||
restore_directory_from_friend $temp_restore_dir syncthingshared
|
||||
cp -r $temp_restore_dir/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 37904
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
fi
|
||||
if [ -d $SERVER_DIRECTORY/backup/syncthingshared ]; then
|
||||
echo $"Restoring syncthing shared files"
|
||||
temp_restore_dir=/root/tempsyncthingshared
|
||||
function_check restore_directory_from_friend
|
||||
restore_directory_from_friend $temp_restore_dir syncthingshared
|
||||
cp -r $temp_restore_dir/* /
|
||||
if [ ! "$?" = "0" ]; then
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 37904
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
fi
|
||||
|
||||
if [ -d $SERVER_DIRECTORY/backup/syncthing ]; then
|
||||
for d in $SERVER_DIRECTORY/backup/syncthing/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
echo $"Restoring syncthing files for $USERNAME"
|
||||
temp_restore_dir=/root/tempsyncthing
|
||||
function_check restore_directory_from_friend
|
||||
restore_directory_from_friend $temp_restore_dir syncthing/$USERNAME
|
||||
cp -r $temp_restore_dir/home/$USERNAME/Sync /home/$USERNAME/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf $temp_restore_dir
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 68438
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
if [ -d $SERVER_DIRECTORY/backup/syncthing ]; then
|
||||
for d in $SERVER_DIRECTORY/backup/syncthing/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
echo $"Restoring syncthing files for $USERNAME"
|
||||
temp_restore_dir=/root/tempsyncthing
|
||||
function_check restore_directory_from_friend
|
||||
restore_directory_from_friend $temp_restore_dir syncthing/$USERNAME
|
||||
cp -r $temp_restore_dir/home/$USERNAME/Sync /home/$USERNAME/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf $temp_restore_dir
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
exit 68438
|
||||
fi
|
||||
rm -rf $temp_restore_dir
|
||||
|
||||
# restore device IDs from config settings
|
||||
if [ -f /home/$USERNAME/.config/syncthing/.syncthing-server-id ]; then
|
||||
cp /home/$USERNAME/.config/syncthing/.syncthing-server-id /home/$USERNAME/.syncthing-server-id
|
||||
chown $USERNAME:$USERNAME /home/$USERNAME/.syncthing-server-id
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.config/syncthing/.syncthingids ]; then
|
||||
cp /home/$USERNAME/.config/syncthing/.syncthingids /home/$USERNAME/.syncthingids
|
||||
chown $USERNAME:$USERNAME /home/$USERNAME/.syncthingids
|
||||
fi
|
||||
echo $"Restore of syncthing files for $USERNAME complete"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# restore device IDs from config settings
|
||||
if [ -f /home/$USERNAME/.config/syncthing/.syncthing-server-id ]; then
|
||||
cp /home/$USERNAME/.config/syncthing/.syncthing-server-id /home/$USERNAME/.syncthing-server-id
|
||||
chown $USERNAME:$USERNAME /home/$USERNAME/.syncthing-server-id
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.config/syncthing/.syncthingids ]; then
|
||||
cp /home/$USERNAME/.config/syncthing/.syncthingids /home/$USERNAME/.syncthingids
|
||||
chown $USERNAME:$USERNAME /home/$USERNAME/.syncthingids
|
||||
fi
|
||||
echo $"Restore of syncthing files for $USERNAME complete"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -f /etc/systemd/system/syncthing.service ]; then
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
fi
|
||||
if [ -f /etc/systemd/system/syncthing.service ]; then
|
||||
systemctl start syncthing
|
||||
systemctl start cron
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_syncthing {
|
||||
if ! grep -Fxq "install_syncthing" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
iptables -D INPUT -p udp --dport $SYNCTHING_PORT -j ACCEPT
|
||||
iptables -D INPUT -p tcp --dport $SYNCTHING_PORT -j ACCEPT
|
||||
function_check save_firewall_settings
|
||||
save_firewall_settings
|
||||
if ! grep -Fxq "install_syncthing" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
iptables -D INPUT -p udp --dport $SYNCTHING_PORT -j ACCEPT
|
||||
iptables -D INPUT -p tcp --dport $SYNCTHING_PORT -j ACCEPT
|
||||
function_check save_firewall_settings
|
||||
save_firewall_settings
|
||||
|
||||
systemctl stop syncthing
|
||||
systemctl disable syncthing
|
||||
apt-get -y remove --purge syncthing
|
||||
rm /etc/systemd/system/syncthing.service
|
||||
sed -i "/${PROJECT_NAME}-syncthing/d" /etc/crontab
|
||||
sed -i '/install_syncthing/d' $COMPLETION_FILE
|
||||
sed -i '/configure_firewall_for_syncthing/d' $COMPLETION_FILE
|
||||
systemctl restart cron
|
||||
systemctl stop syncthing
|
||||
systemctl disable syncthing
|
||||
apt-get -y remove --purge syncthing
|
||||
rm /etc/systemd/system/syncthing.service
|
||||
sed -i "/${PROJECT_NAME}-syncthing/d" /etc/crontab
|
||||
sed -i '/install_syncthing/d' $COMPLETION_FILE
|
||||
sed -i '/configure_firewall_for_syncthing/d' $COMPLETION_FILE
|
||||
systemctl restart cron
|
||||
}
|
||||
|
||||
function configure_firewall_for_syncthing {
|
||||
if grep -Fxq "configure_firewall_for_syncthing" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
iptables -A INPUT -p udp --dport $SYNCTHING_PORT -j ACCEPT
|
||||
iptables -A INPUT -p tcp --dport $SYNCTHING_PORT -j ACCEPT
|
||||
function_check save_firewall_settings
|
||||
save_firewall_settings
|
||||
if grep -Fxq "configure_firewall_for_syncthing" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
iptables -A INPUT -p udp --dport $SYNCTHING_PORT -j ACCEPT
|
||||
iptables -A INPUT -p tcp --dport $SYNCTHING_PORT -j ACCEPT
|
||||
function_check save_firewall_settings
|
||||
save_firewall_settings
|
||||
|
||||
OPEN_PORTS+=("Syncthing $SYNCTHING_PORT")
|
||||
echo 'configure_firewall_for_syncthing' >> $COMPLETION_FILE
|
||||
OPEN_PORTS+=("Syncthing $SYNCTHING_PORT")
|
||||
echo 'configure_firewall_for_syncthing' >> $COMPLETION_FILE
|
||||
}
|
||||
|
||||
function mesh_install_syncthing {
|
||||
chroot "$rootdir" wget -q https://syncthing.net/release-key.txt -O- | apt-key add -
|
||||
chroot "$rootdir" wget -q https://syncthing.net/release-key.txt -O- | apt-key add -
|
||||
|
||||
echo "deb http://apt.syncthing.net/ syncthing release" | tee $rootdir/etc/apt/sources.list.d/syncthing.list
|
||||
chroot "$rootdir" apt-get update
|
||||
chroot "$rootdir" apt-get -y --force-yes install syncthing
|
||||
echo "deb http://apt.syncthing.net/ syncthing release" | tee $rootdir/etc/apt/sources.list.d/syncthing.list
|
||||
chroot "$rootdir" apt-get update
|
||||
chroot "$rootdir" apt-get -y --force-yes install syncthing
|
||||
|
||||
# This probably does need to run as root so that it can access the Sync directories
|
||||
# in each user's home directory
|
||||
echo '[Unit]' > $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'Description=Syncthing - Open Source Continuous File Synchronization' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'Documentation=man:syncthing(1)' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'After=network.target' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'Wants=syncthing-inotify@.service' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo '' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo '[Service]' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'User=root' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'Restart=on-failure' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'SuccessExitStatus=3 4' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'RestartForceExitStatus=3 4' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo '' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo '[Install]' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'WantedBy=multi-user.target' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
chroot "$rootdir" systemctl enable syncthing
|
||||
# This probably does need to run as root so that it can access the Sync directories
|
||||
# in each user's home directory
|
||||
echo '[Unit]' > $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'Description=Syncthing - Open Source Continuous File Synchronization' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'Documentation=man:syncthing(1)' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'After=network.target' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'Wants=syncthing-inotify@.service' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo '' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo '[Service]' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'User=root' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'Restart=on-failure' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'SuccessExitStatus=3 4' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'RestartForceExitStatus=3 4' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo '' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo '[Install]' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
echo 'WantedBy=multi-user.target' >> $rootdir/etc/systemd/system/syncthing.service
|
||||
chroot "$rootdir" systemctl enable syncthing
|
||||
|
||||
echo 'mesh_install_syncthing'
|
||||
echo 'mesh_install_syncthing'
|
||||
}
|
||||
|
||||
function install_syncthing {
|
||||
if [ $INSTALLING_MESH ]; then
|
||||
mesh_install_syncthing
|
||||
return
|
||||
fi
|
||||
if [ $INSTALLING_MESH ]; then
|
||||
mesh_install_syncthing
|
||||
return
|
||||
fi
|
||||
|
||||
if grep -Fxq "install_syncthing" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
if grep -Fxq "install_syncthing" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
|
||||
apt-get -y install curl
|
||||
apt-get -y install curl
|
||||
|
||||
curl -s https://syncthing.net/release-key.txt | apt-key add -
|
||||
echo "deb http://apt.syncthing.net/ syncthing release" | tee /etc/apt/sources.list.d/syncthing.list
|
||||
apt-get update
|
||||
apt-get -y install syncthing
|
||||
curl -s https://syncthing.net/release-key.txt | apt-key add -
|
||||
echo "deb http://apt.syncthing.net/ syncthing release" | tee /etc/apt/sources.list.d/syncthing.list
|
||||
apt-get update
|
||||
apt-get -y install syncthing
|
||||
|
||||
# This probably does need to run as root so that it can access the Sync directories
|
||||
# in each user's home directory
|
||||
echo '[Unit]' > /etc/systemd/system/syncthing.service
|
||||
echo 'Description=Syncthing - Open Source Continuous File Synchronization' >> /etc/systemd/system/syncthing.service
|
||||
echo 'Documentation=man:syncthing(1)' >> /etc/systemd/system/syncthing.service
|
||||
echo 'After=network.target' >> /etc/systemd/system/syncthing.service
|
||||
echo 'Wants=syncthing-inotify@.service' >> /etc/systemd/system/syncthing.service
|
||||
echo '' >> /etc/systemd/system/syncthing.service
|
||||
echo '[Service]' >> /etc/systemd/system/syncthing.service
|
||||
echo 'User=root' >> /etc/systemd/system/syncthing.service
|
||||
echo "Environment='all_proxy=socks5://localhost:9050'" >> /etc/systemd/system/syncthing.service
|
||||
echo 'ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0' >> /etc/systemd/system/syncthing.service
|
||||
echo 'Restart=on-failure' >> /etc/systemd/system/syncthing.service
|
||||
echo 'SuccessExitStatus=3 4' >> /etc/systemd/system/syncthing.service
|
||||
echo 'RestartForceExitStatus=3 4' >> /etc/systemd/system/syncthing.service
|
||||
echo '' >> /etc/systemd/system/syncthing.service
|
||||
echo '[Install]' >> /etc/systemd/system/syncthing.service
|
||||
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/syncthing.service
|
||||
systemctl enable syncthing
|
||||
systemctl daemon-reload
|
||||
systemctl start syncthing
|
||||
# This probably does need to run as root so that it can access the Sync directories
|
||||
# in each user's home directory
|
||||
echo '[Unit]' > /etc/systemd/system/syncthing.service
|
||||
echo 'Description=Syncthing - Open Source Continuous File Synchronization' >> /etc/systemd/system/syncthing.service
|
||||
echo 'Documentation=man:syncthing(1)' >> /etc/systemd/system/syncthing.service
|
||||
echo 'After=network.target' >> /etc/systemd/system/syncthing.service
|
||||
echo 'Wants=syncthing-inotify@.service' >> /etc/systemd/system/syncthing.service
|
||||
echo '' >> /etc/systemd/system/syncthing.service
|
||||
echo '[Service]' >> /etc/systemd/system/syncthing.service
|
||||
echo 'User=root' >> /etc/systemd/system/syncthing.service
|
||||
echo "Environment='all_proxy=socks5://localhost:9050'" >> /etc/systemd/system/syncthing.service
|
||||
echo 'ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0' >> /etc/systemd/system/syncthing.service
|
||||
echo 'Restart=on-failure' >> /etc/systemd/system/syncthing.service
|
||||
echo 'SuccessExitStatus=3 4' >> /etc/systemd/system/syncthing.service
|
||||
echo 'RestartForceExitStatus=3 4' >> /etc/systemd/system/syncthing.service
|
||||
echo '' >> /etc/systemd/system/syncthing.service
|
||||
echo '[Install]' >> /etc/systemd/system/syncthing.service
|
||||
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/syncthing.service
|
||||
systemctl enable syncthing
|
||||
systemctl daemon-reload
|
||||
systemctl start syncthing
|
||||
|
||||
function_check cron_add_mins
|
||||
cron_add_mins 1 "/usr/local/bin/${PROJECT_NAME}-syncthing > /dev/null"
|
||||
function_check cron_add_mins
|
||||
cron_add_mins 1 "/usr/local/bin/${PROJECT_NAME}-syncthing > /dev/null"
|
||||
|
||||
function_check configure_firewall_for_syncthing
|
||||
configure_firewall_for_syncthing
|
||||
echo 'install_syncthing' >> $COMPLETION_FILE
|
||||
function_check configure_firewall_for_syncthing
|
||||
configure_firewall_for_syncthing
|
||||
echo 'install_syncthing' >> $COMPLETION_FILE
|
||||
}
|
||||
|
||||
# NOTE: deliberately no exit 0
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
VARIANTS='mesh'
|
||||
VARIANTS='full mesh'
|
||||
|
||||
TAHOELAFS_REPO="https://github.com/tahoe-lafs/tahoe-lafs"
|
||||
TAHOELAFS_COMMIT='30b421d48b3d1dae2ef507bf27a1f3816300cd92'
|
||||
|
@ -42,7 +42,7 @@ TAHOE_COMMAND="cd /var/lib/tahoelafs && venv/bin/tahoe"
|
|||
function reconfigure_tahoelafs {
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d /home/$USERNAME/.tahoe ]; then
|
||||
su -c "$TAHOE_COMMAND stop" - $USERNAME
|
||||
rm -rf /home/$USERNAME/.tahoe
|
||||
|
@ -257,17 +257,65 @@ function install_tahoelafs {
|
|||
|
||||
apt-get -y install build-essential python-pip python-dev libffi-dev libssl-dev python-virtualenv
|
||||
|
||||
git_clone $TAHOELAFS_REPO /var/lib/tahoelafs
|
||||
cd /var/lib/tahoelafs
|
||||
# create a user to run the introducer
|
||||
if [ ! -d /home/tahoelafs ]; then
|
||||
# add a gogs user account
|
||||
adduser --disabled-login --gecos 'tahoe-lafs' tahoelafs
|
||||
fi
|
||||
|
||||
if [ -d /home/tahoelafs/Maildir ]; then
|
||||
rm -rf /home/tahoelafs/Maildir
|
||||
fi
|
||||
|
||||
if [ ! -d /home/tahoelafs/.tahoe-introducer ]; then
|
||||
mkdir /home/tahoelafs/.tahoe-introducer
|
||||
fi
|
||||
|
||||
git_clone $TAHOELAFS_REPO /home/tahoelafs/tahoelafs
|
||||
cd /home/tahoelafs/tahoelafs
|
||||
git checkout $TAHOELAFS_COMMIT -b $TAHOELAFS_COMMIT
|
||||
virtualenv venv
|
||||
venv/bin/pip install --editable .
|
||||
configure_firewall_for_tahoelafs
|
||||
reconfigure_tahoelafs
|
||||
tahoelafs_update_script /usr/bin/update-tahoelafs
|
||||
|
||||
function_check cron_add_mins
|
||||
cron_add_mins 1 "/usr/bin/update-tahoelafs 2> /dev/null"
|
||||
su -c "cd $TAHOE_COMMAND create-introducer /home/tahoelafs/.tahoe-introducer" - tahoelafs
|
||||
TAHOELAFS_CONFIG=/home/tahoelafs/.tahoe-introducer/tahoe.cfg
|
||||
if [ ! -f $TAHOELAFS_CONFIG ]; then
|
||||
exit 62831
|
||||
fi
|
||||
|
||||
sed -i "s|nickname =.*|nickname = $HOSTNAME|g" $TAHOELAFS_CONFIG
|
||||
|
||||
if ! grep -q "[storage]" $TAHOELAFS_CONFIG; then
|
||||
echo '' >> $TAHOELAFS_CONFIG
|
||||
echo '[storage]' >> $TAHOELAFS_CONFIG
|
||||
echo 'enabled = true' >> $TAHOELAFS_CONFIG
|
||||
echo "reserved_space = $TAHOELAFS_STORAGE_SPACE" >> $TAHOELAFS_CONFIG
|
||||
fi
|
||||
|
||||
chown -R tahoelafs:tahoelafs /home/tahoelafs
|
||||
|
||||
TAHOELAFS_DAEMON_FILE=/etc/systemd/system/tahoelafs.service
|
||||
echo '[Unit]' > $TAHOELAFS_DAEMON_FILE
|
||||
echo 'Description=Tahoe-LAFS introducer' >> $TAHOELAFS_DAEMON_FILE
|
||||
echo 'After=syslog.target' >> $TAHOELAFS_DAEMON_FILE
|
||||
echo 'After=network.target' >> $TAHOELAFS_DAEMON_FILE
|
||||
echo '' >> $TAHOELAFS_DAEMON_FILE
|
||||
echo '[Service]' >> $TAHOELAFS_DAEMON_FILE
|
||||
echo 'Type=simple' >> $TAHOELAFS_DAEMON_FILE
|
||||
echo "User=tahoelafs" >> $TAHOELAFS_DAEMON_FILE
|
||||
echo "Group=tahoelafs" >> $TAHOELAFS_DAEMON_FILE
|
||||
echo "WorkingDirectory=/home/tahoelafs" >> $TAHOELAFS_DAEMON_FILE
|
||||
echo "ExecStart=venv/bin/tahoe start /home/tahoelafs/.tahoe-introducer" >> $TAHOELAFS_DAEMON_FILE
|
||||
echo "ExecStop=venv/bin/tahoe stop /home/tahoelafs/.tahoe-introducer" >> $TAHOELAFS_DAEMON_FILE
|
||||
echo 'Restart=on-failure' >> $TAHOELAFS_DAEMON_FILE
|
||||
echo "Environment=\"USER=tahoelafs\" \"HOME=/home/tahoelafs\"" >> $TAHOELAFS_DAEMON_FILE
|
||||
echo '' >> $TAHOELAFS_DAEMON_FILE
|
||||
echo '[Install]' >> $TAHOELAFS_DAEMON_FILE
|
||||
echo 'WantedBy=multi-user.target' >> $TAHOELAFS_DAEMON_FILE
|
||||
systemctl enable tahoelafs
|
||||
systemctl daemon-reload
|
||||
systemctl start tahoelafs
|
||||
|
||||
echo 'install_tahoelafs' >> $COMPLETION_FILE
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ function remove_xmpp {
|
|||
function xmpp_email_headers {
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -f /home/$USERNAME/.muttrc ]; then
|
||||
if ! grep -q "Jabber-ID" /home/$USERNAME/.muttrc; then
|
||||
echo "my_hdr Jabber-ID: ${USERNAME}@${HOSTNAME}" >> /home/$USERNAME/.muttrc
|
||||
|
|
|
@ -35,7 +35,7 @@ export TEXTDOMAINDIR="/usr/share/locale"
|
|||
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
# for every user who has a mail directory
|
||||
if [ -d /home/$USERNAME/Maildir ]; then
|
||||
MUTTRC=/home/$USERNAME/.muttrc
|
||||
|
|
|
@ -49,9 +49,9 @@ USB_MOUNT=/mnt/usb
|
|||
# get default USB from config file
|
||||
CONFIG_FILE=$HOME/${PROJECT_NAME}.cfg
|
||||
if [ -f $CONFIG_FILE ]; then
|
||||
if grep -q "USB_DRIVE=" $CONFIG_FILE; then
|
||||
USB_DRIVE=$(cat $CONFIG_FILE | grep "USB_DRIVE=" | awk -F '=' '{print $2}')
|
||||
fi
|
||||
if grep -q "USB_DRIVE=" $CONFIG_FILE; then
|
||||
USB_DRIVE=$(cat $CONFIG_FILE | grep "USB_DRIVE=" | awk -F '=' '{print $2}')
|
||||
fi
|
||||
fi
|
||||
|
||||
# get the version of Go being used
|
||||
|
@ -67,333 +67,333 @@ SUSPENDED_SITE=
|
|||
|
||||
DATABASE_PASSWORD=''
|
||||
if [ -f /root/dbpass ]; then
|
||||
DATABASE_PASSWORD=$(cat /root/dbpass)
|
||||
DATABASE_PASSWORD=$(cat /root/dbpass)
|
||||
fi
|
||||
|
||||
function make_backup_directory {
|
||||
# make a backup directory on the drive
|
||||
if [ ! -d $USB_MOUNT/backup ]; then
|
||||
mkdir $USB_MOUNT/backup
|
||||
fi
|
||||
if [ ! -d $USB_MOUNT/backup ]; then
|
||||
echo $"There was a problem making the directory $USB_MOUNT/backup."
|
||||
umount $USB_MOUNT
|
||||
rm -rf $USB_MOUNT
|
||||
exit 3
|
||||
fi
|
||||
# make a backup directory on the drive
|
||||
if [ ! -d $USB_MOUNT/backup ]; then
|
||||
mkdir $USB_MOUNT/backup
|
||||
fi
|
||||
if [ ! -d $USB_MOUNT/backup ]; then
|
||||
echo $"There was a problem making the directory $USB_MOUNT/backup."
|
||||
umount $USB_MOUNT
|
||||
rm -rf $USB_MOUNT
|
||||
exit 3
|
||||
fi
|
||||
}
|
||||
|
||||
function check_storage_space_remaining {
|
||||
# Check space remaining on the usb drive
|
||||
used_percent=$(df -k $USB_MOUNT | tail -n 1 | awk -F ' ' '{print $5}' | awk -F '%' '{print $1}')
|
||||
if [ $used_percent -gt 95 ]; then
|
||||
echo $"Less than 5% of space remaining on backup drive"
|
||||
umount $USB_MOUNT
|
||||
rm -rf $USB_MOUNT
|
||||
exit 4
|
||||
fi
|
||||
# Check space remaining on the usb drive
|
||||
used_percent=$(df -k $USB_MOUNT | tail -n 1 | awk -F ' ' '{print $5}' | awk -F '%' '{print $1}')
|
||||
if [ $used_percent -gt 95 ]; then
|
||||
echo $"Less than 5% of space remaining on backup drive"
|
||||
umount $USB_MOUNT
|
||||
rm -rf $USB_MOUNT
|
||||
exit 4
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_users {
|
||||
# Backup user files
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
# Backup user files
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
|
||||
# Backup any gpg keys
|
||||
if [ -d /home/$USERNAME/.gnupg ]; then
|
||||
echo $"Backing up gpg keys for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.gnupg gnupg/$USERNAME
|
||||
fi
|
||||
# Backup any gpg keys
|
||||
if [ -d /home/$USERNAME/.gnupg ]; then
|
||||
echo $"Backing up gpg keys for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.gnupg gnupg/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup any personal settings
|
||||
if [ -d /home/$USERNAME/personal ]; then
|
||||
echo $"Backing up personal settings for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/personal personal/$USERNAME
|
||||
fi
|
||||
# Backup any personal settings
|
||||
if [ -d /home/$USERNAME/personal ]; then
|
||||
echo $"Backing up personal settings for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/personal personal/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup ssh keys
|
||||
if [ -d /home/$USERNAME/.ssh ]; then
|
||||
echo $"Backing up ssh keys for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.ssh ssh/$USERNAME
|
||||
fi
|
||||
# Backup ssh keys
|
||||
if [ -d /home/$USERNAME/.ssh ]; then
|
||||
echo $"Backing up ssh keys for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.ssh ssh/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup fin database if it exists
|
||||
if [ -d /home/$USERNAME/.fin ]; then
|
||||
echo $"Backing up fin files for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.fin fin/$USERNAME
|
||||
fi
|
||||
# Backup fin database if it exists
|
||||
if [ -d /home/$USERNAME/.fin ]; then
|
||||
echo $"Backing up fin files for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.fin fin/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup syncthing
|
||||
if [ -d /home/$USERNAME/Sync ]; then
|
||||
echo $"Backing up syncthing files for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/Sync syncthing/$USERNAME
|
||||
# ensure that device IDs will be backed up as part of user config settings
|
||||
if [ ! -d /home/$USERNAME/.config/syncthing ]; then
|
||||
mkdir -p /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.syncthing-server-id ]; then
|
||||
cp /home/$USERNAME/.syncthing-server-id /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.syncthingids ]; then
|
||||
cp /home/$USERNAME/.syncthingids /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
fi
|
||||
# Backup syncthing
|
||||
if [ -d /home/$USERNAME/Sync ]; then
|
||||
echo $"Backing up syncthing files for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/Sync syncthing/$USERNAME
|
||||
# ensure that device IDs will be backed up as part of user config settings
|
||||
if [ ! -d /home/$USERNAME/.config/syncthing ]; then
|
||||
mkdir -p /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.syncthing-server-id ]; then
|
||||
cp /home/$USERNAME/.syncthing-server-id /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.syncthingids ]; then
|
||||
cp /home/$USERNAME/.syncthingids /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
fi
|
||||
|
||||
# Backup emacs
|
||||
if [ -d /home/$USERNAME/.emacs.d ]; then
|
||||
echo $"Backing up Emacs config for $USERNAME"
|
||||
if [ -f /home/$USERNAME/.emacs ]; then
|
||||
cp /home/$USERNAME/.emacs /home/$USERNAME/.emacs.d/dotemacs
|
||||
fi
|
||||
backup_directory_to_usb /home/$USERNAME/.emacs.d config/$USERNAME
|
||||
fi
|
||||
# Backup emacs
|
||||
if [ -d /home/$USERNAME/.emacs.d ]; then
|
||||
echo $"Backing up Emacs config for $USERNAME"
|
||||
if [ -f /home/$USERNAME/.emacs ]; then
|
||||
cp /home/$USERNAME/.emacs /home/$USERNAME/.emacs.d/dotemacs
|
||||
fi
|
||||
backup_directory_to_usb /home/$USERNAME/.emacs.d config/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup user configs
|
||||
if [ -d /home/$USERNAME/.config ]; then
|
||||
echo $"Backing up config files for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.config config/$USERNAME
|
||||
fi
|
||||
# Backup user configs
|
||||
if [ -d /home/$USERNAME/.config ]; then
|
||||
echo $"Backing up config files for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.config config/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup monkeysphere
|
||||
if [ -d /home/$USERNAME/.monkeysphere ]; then
|
||||
echo $"Backing up monkeysphere files for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.monkeysphere monkeysphere/$USERNAME
|
||||
fi
|
||||
# Backup monkeysphere
|
||||
if [ -d /home/$USERNAME/.monkeysphere ]; then
|
||||
echo $"Backing up monkeysphere files for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.monkeysphere monkeysphere/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup user local
|
||||
if [ -d /home/$USERNAME/.local ]; then
|
||||
echo $"Backing up local files for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.local local/$USERNAME
|
||||
fi
|
||||
# Backup user local
|
||||
if [ -d /home/$USERNAME/.local ]; then
|
||||
echo $"Backing up local files for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.local local/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup mutt
|
||||
if [ -f /home/$USERNAME/.muttrc ]; then
|
||||
echo $"Backing up Mutt settings for $USERNAME"
|
||||
if [ ! -d /home/$USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$USERNAME/tempbackup
|
||||
fi
|
||||
cp /home/$USERNAME/.muttrc /home/$USERNAME/tempbackup
|
||||
if [ -f /etc/Muttrc ]; then
|
||||
cp /etc/Muttrc /home/$USERNAME/tempbackup
|
||||
fi
|
||||
backup_directory_to_usb /home/$USERNAME/tempbackup mutt/$USERNAME
|
||||
fi
|
||||
# Backup mutt
|
||||
if [ -f /home/$USERNAME/.muttrc ]; then
|
||||
echo $"Backing up Mutt settings for $USERNAME"
|
||||
if [ ! -d /home/$USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$USERNAME/tempbackup
|
||||
fi
|
||||
cp /home/$USERNAME/.muttrc /home/$USERNAME/tempbackup
|
||||
if [ -f /etc/Muttrc ]; then
|
||||
cp /etc/Muttrc /home/$USERNAME/tempbackup
|
||||
fi
|
||||
backup_directory_to_usb /home/$USERNAME/tempbackup mutt/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup email
|
||||
if [ -d /home/$USERNAME/Maildir ]; then
|
||||
echo $"Stopping mail server"
|
||||
systemctl stop exim4
|
||||
echo $"Creating an email archive for $USERNAME"
|
||||
if [ ! -d /root/tempbackupemail/$USERNAME ]; then
|
||||
mkdir -p /root/tempbackupemail/$USERNAME
|
||||
fi
|
||||
tar -czvf /root/tempbackupemail/$USERNAME/maildir.tar.gz /home/$USERNAME/Maildir
|
||||
echo $"Restarting mail server"
|
||||
systemctl start exim4
|
||||
echo $"Backing up emails for $USERNAME"
|
||||
backup_directory_to_usb /root/tempbackupemail/$USERNAME mail/$USERNAME
|
||||
fi
|
||||
# Backup email
|
||||
if [ -d /home/$USERNAME/Maildir ]; then
|
||||
echo $"Stopping mail server"
|
||||
systemctl stop exim4
|
||||
echo $"Creating an email archive for $USERNAME"
|
||||
if [ ! -d /root/tempbackupemail/$USERNAME ]; then
|
||||
mkdir -p /root/tempbackupemail/$USERNAME
|
||||
fi
|
||||
tar -czvf /root/tempbackupemail/$USERNAME/maildir.tar.gz /home/$USERNAME/Maildir
|
||||
echo $"Restarting mail server"
|
||||
systemctl start exim4
|
||||
echo $"Backing up emails for $USERNAME"
|
||||
backup_directory_to_usb /root/tempbackupemail/$USERNAME mail/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup spamassassin
|
||||
if [ -d /home/$USERNAME/.spamassassin ]; then
|
||||
echo $"Backing up spamassassin settings for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.spamassassin spamassassin/$USERNAME
|
||||
fi
|
||||
# Backup spamassassin
|
||||
if [ -d /home/$USERNAME/.spamassassin ]; then
|
||||
echo $"Backing up spamassassin settings for $USERNAME"
|
||||
backup_directory_to_usb /home/$USERNAME/.spamassassin spamassassin/$USERNAME
|
||||
fi
|
||||
|
||||
# Backup procmail
|
||||
if [ -f /home/$USERNAME/.procmailrc ]; then
|
||||
echo $"Backing up procmail settings for $USERNAME"
|
||||
if [ ! -d /home/$USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$USERNAME/tempbackup
|
||||
fi
|
||||
cp /home/$USERNAME/.procmailrc /home/$USERNAME/tempbackup
|
||||
backup_directory_to_usb /home/$USERNAME/tempbackup procmail/$USERNAME
|
||||
fi
|
||||
fi
|
||||
done
|
||||
# Backup procmail
|
||||
if [ -f /home/$USERNAME/.procmailrc ]; then
|
||||
echo $"Backing up procmail settings for $USERNAME"
|
||||
if [ ! -d /home/$USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$USERNAME/tempbackup
|
||||
fi
|
||||
cp /home/$USERNAME/.procmailrc /home/$USERNAME/tempbackup
|
||||
backup_directory_to_usb /home/$USERNAME/tempbackup procmail/$USERNAME
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function backup_directories {
|
||||
export GVM_ROOT=$GVM_HOME
|
||||
if [ -d $GVM_ROOT/bin ]; then
|
||||
cd $GVM_ROOT/bin
|
||||
[[ -s "$GVM_ROOT/scripts/gvm" ]] && source "$GVM_ROOT/scripts/gvm"
|
||||
gvm use go${GO_VERSION} --default
|
||||
systemctl set-environment GOPATH=$GOPATH
|
||||
fi
|
||||
export GVM_ROOT=$GVM_HOME
|
||||
if [ -d $GVM_ROOT/bin ]; then
|
||||
cd $GVM_ROOT/bin
|
||||
[[ -s "$GVM_ROOT/scripts/gvm" ]] && source "$GVM_ROOT/scripts/gvm"
|
||||
gvm use go${GO_VERSION} --default
|
||||
systemctl set-environment GOPATH=$GOPATH
|
||||
fi
|
||||
|
||||
# directories to be backed up (source,dest)
|
||||
backup_dirs=(
|
||||
"/etc/letsencrypt, letsencrypt"
|
||||
"/etc/ssl, ssl"
|
||||
"/var/spool/mlmmj, mailinglist"
|
||||
"/etc/nginx/sites-available, web"
|
||||
"/var/lib/tor, tor"
|
||||
)
|
||||
# directories to be backed up (source,dest)
|
||||
backup_dirs=(
|
||||
"/etc/letsencrypt, letsencrypt"
|
||||
"/etc/ssl, ssl"
|
||||
"/var/spool/mlmmj, mailinglist"
|
||||
"/etc/nginx/sites-available, web"
|
||||
"/var/lib/tor, tor"
|
||||
)
|
||||
|
||||
for dr in "${backup_dirs[@]}"
|
||||
do
|
||||
# if this directory exists then back it up to the given destination
|
||||
source_directory=$(echo $dr | awk -F ',' '{print $1}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
if [ -d $source_directory ]; then
|
||||
dest_directory=$(echo $dr | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
echo $"Backing up $source_directory to $dest_directory"
|
||||
backup_directory_to_usb $source_directory $dest_directory
|
||||
fi
|
||||
for dr in "${backup_dirs[@]}"
|
||||
do
|
||||
# if this directory exists then back it up to the given destination
|
||||
source_directory=$(echo $dr | awk -F ',' '{print $1}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
if [ -d $source_directory ]; then
|
||||
dest_directory=$(echo $dr | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
echo $"Backing up $source_directory to $dest_directory"
|
||||
backup_directory_to_usb $source_directory $dest_directory
|
||||
fi
|
||||
|
||||
restart_site
|
||||
done
|
||||
restart_site
|
||||
done
|
||||
}
|
||||
|
||||
function remove_backup_directory {
|
||||
if [ $1 ]; then
|
||||
if [[ $1 == "remove" ]]; then
|
||||
if [ -d $USB_MOUNT/backup ]; then
|
||||
rm -rf $USB_MOUNT/backup
|
||||
echo $'Existing backup directory removed'
|
||||
backup_unmount_drive
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ $1 ]; then
|
||||
if [[ $1 == "remove" ]]; then
|
||||
if [ -d $USB_MOUNT/backup ]; then
|
||||
rm -rf $USB_MOUNT/backup
|
||||
echo $'Existing backup directory removed'
|
||||
backup_unmount_drive
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function prepare_directories {
|
||||
export GVM_ROOT=$GVM_HOME
|
||||
if [ -d $GVM_ROOT/bin ]; then
|
||||
cd $GVM_ROOT/bin
|
||||
[[ -s "$GVM_ROOT/scripts/gvm" ]] && source "$GVM_ROOT/scripts/gvm"
|
||||
gvm use go${GO_VERSION} --default
|
||||
systemctl set-environment GOPATH=$GOPATH
|
||||
fi
|
||||
export GVM_ROOT=$GVM_HOME
|
||||
if [ -d $GVM_ROOT/bin ]; then
|
||||
cd $GVM_ROOT/bin
|
||||
[[ -s "$GVM_ROOT/scripts/gvm" ]] && source "$GVM_ROOT/scripts/gvm"
|
||||
gvm use go${GO_VERSION} --default
|
||||
systemctl set-environment GOPATH=$GOPATH
|
||||
fi
|
||||
|
||||
# Some miscellaneous preparation for backing up directories
|
||||
if [ -d $GOPATH/src/github.com/gogits ]; then
|
||||
mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$ADMIN_USERNAME
|
||||
fi
|
||||
if [ -d /var/lib/tox-bootstrapd ]; then
|
||||
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
|
||||
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
|
||||
rm -rf /var/lib/tox-bootstrapd/Maildir
|
||||
fi
|
||||
fi
|
||||
# Some miscellaneous preparation for backing up directories
|
||||
if [ -d $GOPATH/src/github.com/gogits ]; then
|
||||
mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$ADMIN_USERNAME
|
||||
fi
|
||||
if [ -d /var/lib/tox-bootstrapd ]; then
|
||||
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
|
||||
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
|
||||
rm -rf /var/lib/tox-bootstrapd/Maildir
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_configuration {
|
||||
echo $"Backing up ${PROJECT_NAME} configuration files"
|
||||
temp_backup_dir=/root/tempbackupconfig
|
||||
if [ ! -d $temp_backup_dir ]; then
|
||||
mkdir -p $temp_backup_dir
|
||||
fi
|
||||
cp -f $CONFIG_FILE $temp_backup_dir
|
||||
cp -f $COMPLETION_FILE $temp_backup_dir
|
||||
if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
||||
cp -f $BACKUP_EXTRA_DIRECTORIES $temp_backup_dir
|
||||
fi
|
||||
# nginx password hashes
|
||||
if [ -f /etc/nginx/.htpasswd ]; then
|
||||
cp -f /etc/nginx/.htpasswd $temp_backup_dir/htpasswd
|
||||
fi
|
||||
backup_directory_to_usb $temp_backup_dir config
|
||||
echo $"Backing up ${PROJECT_NAME} configuration files"
|
||||
temp_backup_dir=/root/tempbackupconfig
|
||||
if [ ! -d $temp_backup_dir ]; then
|
||||
mkdir -p $temp_backup_dir
|
||||
fi
|
||||
cp -f $CONFIG_FILE $temp_backup_dir
|
||||
cp -f $COMPLETION_FILE $temp_backup_dir
|
||||
if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
||||
cp -f $BACKUP_EXTRA_DIRECTORIES $temp_backup_dir
|
||||
fi
|
||||
# nginx password hashes
|
||||
if [ -f /etc/nginx/.htpasswd ]; then
|
||||
cp -f /etc/nginx/.htpasswd $temp_backup_dir/htpasswd
|
||||
fi
|
||||
backup_directory_to_usb $temp_backup_dir config
|
||||
}
|
||||
|
||||
function backup_admin_readme {
|
||||
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
||||
echo $"Backing up README"
|
||||
temp_backup_dir=/home/$ADMIN_USERNAME/tempbackup
|
||||
if [ ! -d $temp_backup_dir ]; then
|
||||
mkdir -p $temp_backup_dir
|
||||
fi
|
||||
cp -f /home/$ADMIN_USERNAME/README $temp_backup_dir
|
||||
backup_directory_to_usb $temp_backup_dir readme
|
||||
fi
|
||||
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
||||
echo $"Backing up README"
|
||||
temp_backup_dir=/home/$ADMIN_USERNAME/tempbackup
|
||||
if [ ! -d $temp_backup_dir ]; then
|
||||
mkdir -p $temp_backup_dir
|
||||
fi
|
||||
cp -f /home/$ADMIN_USERNAME/README $temp_backup_dir
|
||||
backup_directory_to_usb $temp_backup_dir readme
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_mariadb {
|
||||
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
|
||||
temp_backup_dir=/root/tempmariadb
|
||||
if [ ! -d $temp_backup_dir ]; then
|
||||
mkdir $temp_backup_dir
|
||||
fi
|
||||
mysqldump --lock-tables --password="$DATABASE_PASSWORD" mysql user > $temp_backup_dir/mysql.sql
|
||||
if [ ! -s $temp_backup_dir/mysql.sql ]; then
|
||||
echo $"Unable to backup mysql settings"
|
||||
rm -rf $temp_backup_dir
|
||||
umount $USB_MOUNT
|
||||
rm -rf $USB_MOUNT
|
||||
exit 8
|
||||
fi
|
||||
echo "$DATABASE_PASSWORD" > $temp_backup_dir/db
|
||||
chmod 400 $temp_backup_dir/db
|
||||
backup_directory_to_usb $temp_backup_dir mariadb
|
||||
fi
|
||||
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
|
||||
temp_backup_dir=/root/tempmariadb
|
||||
if [ ! -d $temp_backup_dir ]; then
|
||||
mkdir $temp_backup_dir
|
||||
fi
|
||||
mysqldump --lock-tables --password="$DATABASE_PASSWORD" mysql user > $temp_backup_dir/mysql.sql
|
||||
if [ ! -s $temp_backup_dir/mysql.sql ]; then
|
||||
echo $"Unable to backup mysql settings"
|
||||
rm -rf $temp_backup_dir
|
||||
umount $USB_MOUNT
|
||||
rm -rf $USB_MOUNT
|
||||
exit 8
|
||||
fi
|
||||
echo "$DATABASE_PASSWORD" > $temp_backup_dir/db
|
||||
chmod 400 $temp_backup_dir/db
|
||||
backup_directory_to_usb $temp_backup_dir mariadb
|
||||
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" == "ttrss" || \
|
||||
"$destination_dir" == "blog" || \
|
||||
"$destination_dir" == "syncthingconfig" || \
|
||||
"$destination_dir" == "syncthingshared" || \
|
||||
"$destination_dir" == "syncthing" || \
|
||||
"$destination_dir" == "mediagoblin" || \
|
||||
"$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" == "ttrss" || \
|
||||
"$destination_dir" == "blog" || \
|
||||
"$destination_dir" == "syncthingconfig" || \
|
||||
"$destination_dir" == "syncthingshared" || \
|
||||
"$destination_dir" == "syncthing" || \
|
||||
"$destination_dir" == "mediagoblin" || \
|
||||
"$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_usb "$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_usb "$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
|
||||
}
|
||||
|
||||
# has the remove option been set ?
|
||||
remove_option=$2
|
||||
if [[ $1 == "remove" ]]; then
|
||||
remove_option=$1
|
||||
remove_option=$1
|
||||
fi
|
||||
|
||||
backup_mount_drive $1 $2
|
||||
|
|
|
@ -54,27 +54,27 @@ ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $
|
|||
ADMIN_NAME=$(getent passwd $ADMIN_USERNAME | cut -d: -f5 | cut -d, -f1)
|
||||
ADMIN_EMAIL_ADDRESS=${ADMIN_USERNAME}@${HOSTNAME}
|
||||
if [ ! -f /etc/ssl/private/backup.key ]; then
|
||||
echo $"Creating backup key"
|
||||
${PROJECT_NAME}-addcert -h backup --dhkey 2048
|
||||
echo $"Creating backup key"
|
||||
${PROJECT_NAME}-addcert -h backup --dhkey 2048
|
||||
fi
|
||||
|
||||
if [ ! -f /home/${ADMIN_USERNAME}/backup.list ]; then
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# MariaDB password
|
||||
DATABASE_PASSWORD=''
|
||||
if [ -f /root/dbpass ]; then
|
||||
DATABASE_PASSWORD=$(cat /root/dbpass)
|
||||
DATABASE_PASSWORD=$(cat /root/dbpass)
|
||||
fi
|
||||
|
||||
# local directory where the backup will be made
|
||||
if [ ! -d $SERVER_DIRECTORY ]; then
|
||||
mkdir $SERVER_DIRECTORY
|
||||
mkdir $SERVER_DIRECTORY
|
||||
fi
|
||||
|
||||
if [ ! -d $SERVER_DIRECTORY/backup ]; then
|
||||
mkdir -p $SERVER_DIRECTORY/backup
|
||||
mkdir -p $SERVER_DIRECTORY/backup
|
||||
fi
|
||||
|
||||
# The name of a currently suspended site
|
||||
|
@ -82,392 +82,392 @@ fi
|
|||
SUSPENDED_SITE=
|
||||
|
||||
function suspend_site {
|
||||
# suspends a given website
|
||||
if [[ $ENABLE_VERIFICATION != "yes" ]]; then
|
||||
return
|
||||
fi
|
||||
SUSPENDED_SITE="$1"
|
||||
nginx_dissite $SUSPENDED_SITE
|
||||
service nginx reload
|
||||
# suspends a given website
|
||||
if [[ $ENABLE_VERIFICATION != "yes" ]]; then
|
||||
return
|
||||
fi
|
||||
SUSPENDED_SITE="$1"
|
||||
nginx_dissite $SUSPENDED_SITE
|
||||
service nginx reload
|
||||
}
|
||||
|
||||
function restart_site {
|
||||
# restarts a given website
|
||||
if [ ! $SUSPENDED_SITE ]; then
|
||||
return
|
||||
fi
|
||||
nginx_ensite $SUSPENDED_SITE
|
||||
service nginx reload
|
||||
SUSPENDED_SITE=
|
||||
# restarts a given website
|
||||
if [ ! $SUSPENDED_SITE ]; then
|
||||
return
|
||||
fi
|
||||
nginx_ensite $SUSPENDED_SITE
|
||||
service nginx reload
|
||||
SUSPENDED_SITE=
|
||||
}
|
||||
|
||||
function backup_configuration {
|
||||
echo $"Backing up ${PROJECT_NAME} configuration files"
|
||||
temp_backup_dir=/root/tempbackupconfig
|
||||
if [ ! -d $temp_backup_dir ]; then
|
||||
mkdir -p $temp_backup_dir
|
||||
fi
|
||||
cp -f $CONFIG_FILE $temp_backup_dir
|
||||
cp -f $COMPLETION_FILE $temp_backup_dir
|
||||
if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
||||
cp -f $BACKUP_EXTRA_DIRECTORIES $temp_backup_dir
|
||||
fi
|
||||
# nginx password hashes
|
||||
if [ -f /etc/nginx/.htpasswd ]; then
|
||||
cp -f /etc/nginx/.htpasswd $temp_backup_dir/htpasswd
|
||||
fi
|
||||
backup_directory_to_friend $temp_backup_dir config
|
||||
echo $"Backing up ${PROJECT_NAME} configuration files"
|
||||
temp_backup_dir=/root/tempbackupconfig
|
||||
if [ ! -d $temp_backup_dir ]; then
|
||||
mkdir -p $temp_backup_dir
|
||||
fi
|
||||
cp -f $CONFIG_FILE $temp_backup_dir
|
||||
cp -f $COMPLETION_FILE $temp_backup_dir
|
||||
if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
||||
cp -f $BACKUP_EXTRA_DIRECTORIES $temp_backup_dir
|
||||
fi
|
||||
# nginx password hashes
|
||||
if [ -f /etc/nginx/.htpasswd ]; then
|
||||
cp -f /etc/nginx/.htpasswd $temp_backup_dir/htpasswd
|
||||
fi
|
||||
backup_directory_to_friend $temp_backup_dir config
|
||||
}
|
||||
|
||||
function backup_users {
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
|
||||
# personal settings
|
||||
if [ -d /home/$USERNAME/personal ]; then
|
||||
echo $"Backing up personal settings for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/personal personal/$USERNAME
|
||||
fi
|
||||
# personal settings
|
||||
if [ -d /home/$USERNAME/personal ]; then
|
||||
echo $"Backing up personal settings for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/personal personal/$USERNAME
|
||||
fi
|
||||
|
||||
# gpg keys
|
||||
if [ -d /home/$USERNAME/.gnupg ]; then
|
||||
echo $"Backing up gpg keys for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.gnupg gnupg/$USERNAME
|
||||
fi
|
||||
# gpg keys
|
||||
if [ -d /home/$USERNAME/.gnupg ]; then
|
||||
echo $"Backing up gpg keys for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.gnupg gnupg/$USERNAME
|
||||
fi
|
||||
|
||||
# ssh keys
|
||||
if [ -d /home/$USERNAME/.ssh ]; then
|
||||
echo $"Backing up ssh keys for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.ssh ssh/$USERNAME
|
||||
fi
|
||||
# ssh keys
|
||||
if [ -d /home/$USERNAME/.ssh ]; then
|
||||
echo $"Backing up ssh keys for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.ssh ssh/$USERNAME
|
||||
fi
|
||||
|
||||
# syncthing files
|
||||
if [ -d /home/$USERNAME/Sync ]; then
|
||||
echo $"Backing up syncthing files for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/Sync syncthing/$USERNAME
|
||||
# ensure that device IDs will be backed up as part of user config settings
|
||||
if [ ! -d /home/$USERNAME/.config/syncthing ]; then
|
||||
mkdir -p /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.syncthing-server-id ]; then
|
||||
cp /home/$USERNAME/.syncthing-server-id /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.syncthingids ]; then
|
||||
cp /home/$USERNAME/.syncthingids /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
fi
|
||||
# syncthing files
|
||||
if [ -d /home/$USERNAME/Sync ]; then
|
||||
echo $"Backing up syncthing files for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/Sync syncthing/$USERNAME
|
||||
# ensure that device IDs will be backed up as part of user config settings
|
||||
if [ ! -d /home/$USERNAME/.config/syncthing ]; then
|
||||
mkdir -p /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.syncthing-server-id ]; then
|
||||
cp /home/$USERNAME/.syncthing-server-id /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
if [ -f /home/$USERNAME/.syncthingids ]; then
|
||||
cp /home/$USERNAME/.syncthingids /home/$USERNAME/.config/syncthing
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
|
||||
fi
|
||||
fi
|
||||
|
||||
# config files
|
||||
if [ -d /home/$USERNAME/.config ]; then
|
||||
echo $"Backing up config files for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.config config/$USERNAME
|
||||
fi
|
||||
# config files
|
||||
if [ -d /home/$USERNAME/.config ]; then
|
||||
echo $"Backing up config files for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.config config/$USERNAME
|
||||
fi
|
||||
|
||||
# monkeysphere files
|
||||
if [ -d /home/$USERNAME/.monkeysphere ]; then
|
||||
echo $"Backing up monkeysphere files for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.monkeysphere monkeysphere/$USERNAME
|
||||
fi
|
||||
# monkeysphere files
|
||||
if [ -d /home/$USERNAME/.monkeysphere ]; then
|
||||
echo $"Backing up monkeysphere files for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.monkeysphere monkeysphere/$USERNAME
|
||||
fi
|
||||
|
||||
# fin files
|
||||
if [ -d /home/$USERNAME/.fin ]; then
|
||||
echo $"Backing up fin files for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.fin fin/$USERNAME
|
||||
fi
|
||||
# fin files
|
||||
if [ -d /home/$USERNAME/.fin ]; then
|
||||
echo $"Backing up fin files for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.fin fin/$USERNAME
|
||||
fi
|
||||
|
||||
# local files
|
||||
if [ -d /home/$USERNAME/.local ]; then
|
||||
echo $"Backing up local files for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.local local/$USERNAME
|
||||
fi
|
||||
# local files
|
||||
if [ -d /home/$USERNAME/.local ]; then
|
||||
echo $"Backing up local files for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.local local/$USERNAME
|
||||
fi
|
||||
|
||||
# mutt settings
|
||||
if [ -f /home/$USERNAME/.muttrc ]; then
|
||||
echo $"Backing up Mutt settings for $USERNAME"
|
||||
if [ ! -d /home/$USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$USERNAME/tempbackup
|
||||
fi
|
||||
cp /home/$USERNAME/.muttrc /home/$USERNAME/tempbackup
|
||||
if [ -f /etc/Muttrc ]; then
|
||||
cp /etc/Muttrc /home/$USERNAME/tempbackup
|
||||
fi
|
||||
backup_directory_to_friend /home/$USERNAME/tempbackup mutt/$USERNAME
|
||||
fi
|
||||
# mutt settings
|
||||
if [ -f /home/$USERNAME/.muttrc ]; then
|
||||
echo $"Backing up Mutt settings for $USERNAME"
|
||||
if [ ! -d /home/$USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$USERNAME/tempbackup
|
||||
fi
|
||||
cp /home/$USERNAME/.muttrc /home/$USERNAME/tempbackup
|
||||
if [ -f /etc/Muttrc ]; then
|
||||
cp /etc/Muttrc /home/$USERNAME/tempbackup
|
||||
fi
|
||||
backup_directory_to_friend /home/$USERNAME/tempbackup mutt/$USERNAME
|
||||
fi
|
||||
|
||||
# procmail settings
|
||||
if [ -f /home/$USERNAME/.procmailrc ]; then
|
||||
echo $"Backing up procmail settings for $USERNAME"
|
||||
if [ ! -d /home/$USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$USERNAME/tempbackup
|
||||
fi
|
||||
cp /home/$USERNAME/.procmailrc /home/$USERNAME/tempbackup
|
||||
backup_directory_to_friend /home/$USERNAME/tempbackup procmail/$USERNAME
|
||||
fi
|
||||
# procmail settings
|
||||
if [ -f /home/$USERNAME/.procmailrc ]; then
|
||||
echo $"Backing up procmail settings for $USERNAME"
|
||||
if [ ! -d /home/$USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$USERNAME/tempbackup
|
||||
fi
|
||||
cp /home/$USERNAME/.procmailrc /home/$USERNAME/tempbackup
|
||||
backup_directory_to_friend /home/$USERNAME/tempbackup procmail/$USERNAME
|
||||
fi
|
||||
|
||||
# spamassassin settings
|
||||
if [ -d /home/$USERNAME/.spamassassin ]; then
|
||||
echo $"Backing up spamassassin settings for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.spamassassin spamassassin/$USERNAME
|
||||
fi
|
||||
# spamassassin settings
|
||||
if [ -d /home/$USERNAME/.spamassassin ]; then
|
||||
echo $"Backing up spamassassin settings for $USERNAME"
|
||||
backup_directory_to_friend /home/$USERNAME/.spamassassin spamassassin/$USERNAME
|
||||
fi
|
||||
|
||||
# email
|
||||
if [ -d /home/$USERNAME/Maildir ]; then
|
||||
echo $"Stopping mail server"
|
||||
systemctl stop exim4
|
||||
echo $"Creating an email archive"
|
||||
if [ ! -d /root/backupemail/$USERNAME ]; then
|
||||
mkdir -p /root/backupemail/$USERNAME
|
||||
fi
|
||||
tar -czvf /root/backupemail/$USERNAME/maildir.tar.gz /home/$USERNAME/Maildir
|
||||
echo $"Restarting mail server"
|
||||
systemctl start exim4
|
||||
echo $"Backing up emails for $USERNAME"
|
||||
backup_directory_to_friend /root/backupemail/$USERNAME mail/$USERNAME
|
||||
fi
|
||||
fi
|
||||
done
|
||||
# email
|
||||
if [ -d /home/$USERNAME/Maildir ]; then
|
||||
echo $"Stopping mail server"
|
||||
systemctl stop exim4
|
||||
echo $"Creating an email archive"
|
||||
if [ ! -d /root/backupemail/$USERNAME ]; then
|
||||
mkdir -p /root/backupemail/$USERNAME
|
||||
fi
|
||||
tar -czvf /root/backupemail/$USERNAME/maildir.tar.gz /home/$USERNAME/Maildir
|
||||
echo $"Restarting mail server"
|
||||
systemctl start exim4
|
||||
echo $"Backing up emails for $USERNAME"
|
||||
backup_directory_to_friend /root/backupemail/$USERNAME mail/$USERNAME
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function backup_letsencrypt {
|
||||
if [ -d /etc/letsencrypt ]; then
|
||||
echo $"Backing up Lets Encrypt settings"
|
||||
backup_directory_to_friend /etc/letsencrypt letsencrypt
|
||||
fi
|
||||
if [ -d /etc/letsencrypt ]; then
|
||||
echo $"Backing up Lets Encrypt settings"
|
||||
backup_directory_to_friend /etc/letsencrypt letsencrypt
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_tor {
|
||||
if [ -d /etc/letsencrypt ]; then
|
||||
echo $"Backing up Tor settings"
|
||||
backup_directory_to_friend /var/lib/tor tor
|
||||
fi
|
||||
if [ -d /etc/letsencrypt ]; then
|
||||
echo $"Backing up Tor settings"
|
||||
backup_directory_to_friend /var/lib/tor tor
|
||||
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_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_mariadb {
|
||||
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
|
||||
temp_backup_dir=/root/tempmariadb
|
||||
if [ ! -d $temp_backup_dir ]; then
|
||||
mkdir $temp_backup_dir
|
||||
fi
|
||||
mysqldump --password=$DATABASE_PASSWORD mysql user > $temp_backup_dir/mysql.sql
|
||||
if [ ! -s $temp_backup_dir/mysql.sql ]; then
|
||||
echo $"Unable to backup MariaDB settings"
|
||||
rm -rf $temp_backup_dir
|
||||
# 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" > $temp_backup_dir/db
|
||||
chmod 400 $temp_backup_dir/db
|
||||
backup_directory_to_friend $temp_backup_dir mariadb
|
||||
fi
|
||||
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
|
||||
temp_backup_dir=/root/tempmariadb
|
||||
if [ ! -d $temp_backup_dir ]; then
|
||||
mkdir $temp_backup_dir
|
||||
fi
|
||||
mysqldump --password=$DATABASE_PASSWORD mysql user > $temp_backup_dir/mysql.sql
|
||||
if [ ! -s $temp_backup_dir/mysql.sql ]; then
|
||||
echo $"Unable to backup MariaDB settings"
|
||||
rm -rf $temp_backup_dir
|
||||
# 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" > $temp_backup_dir/db
|
||||
chmod 400 $temp_backup_dir/db
|
||||
backup_directory_to_friend $temp_backup_dir 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" == "syncthing" || \
|
||||
"$destination_dir" == "syncthingconfig" || \
|
||||
"$destination_dir" == "syncthingshared" || \
|
||||
"$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" == "syncthing" || \
|
||||
"$destination_dir" == "syncthingconfig" || \
|
||||
"$destination_dir" == "syncthingshared" || \
|
||||
"$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_web_server
|
||||
backup_admin_readme
|
||||
backup_mariadb
|
||||
backup_certs
|
||||
backup_mailing_list
|
||||
backup_apps remote
|
||||
backup_extra_directories
|
||||
backup_users
|
||||
backup_letsencrypt
|
||||
backup_tor
|
||||
backup_web_server
|
||||
backup_admin_readme
|
||||
backup_mariadb
|
||||
backup_certs
|
||||
backup_mailing_list
|
||||
backup_apps remote
|
||||
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" && $USERNAME != "sync" ]]; 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" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; 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
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -238,7 +238,7 @@ function restore_mutt_settings {
|
|||
if [ -d $USB_MOUNT/backup/mutt ]; then
|
||||
for d in $USB_MOUNT/backup/mutt/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
|
@ -272,7 +272,7 @@ function restore_gpg {
|
|||
if [ -d $USB_MOUNT/backup/gnupg ]; then
|
||||
for d in $USB_MOUNT/backup/gnupg/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
|
@ -309,7 +309,7 @@ function restore_procmail {
|
|||
if [ -d $USB_MOUNT/backup/procmail ]; then
|
||||
for d in $USB_MOUNT/backup/procmail/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
|
@ -338,7 +338,7 @@ function restore_spamassassin {
|
|||
if [ -d $USB_MOUNT/backup/spamassassin ]; then
|
||||
for d in $USB_MOUNT/backup/spamassassin/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $USB_MOUNT/backup/spamassassin/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -399,7 +399,7 @@ function restore_user_ssh_keys {
|
|||
if [ -d $USB_MOUNT/backup/ssh ]; then
|
||||
for d in $USB_MOUNT/backup/ssh/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
|
@ -428,7 +428,7 @@ function restore_user_config {
|
|||
if [ -d $USB_MOUNT/backup/config ]; then
|
||||
for d in $USB_MOUNT/backup/config/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
|
@ -469,7 +469,7 @@ function restore_user_monkeysphere {
|
|||
if [ -d $USB_MOUNT/backup/monkeysphere ]; then
|
||||
for d in $USB_MOUNT/backup/monkeysphere/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
|
@ -508,7 +508,7 @@ function restore_user_fin {
|
|||
if [ -d $USB_MOUNT/backup/fin ]; then
|
||||
for d in $USB_MOUNT/backup/fin/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
|
@ -537,7 +537,7 @@ function restore_user_local {
|
|||
if [ -d $USB_MOUNT/backup/local ]; then
|
||||
for d in $USB_MOUNT/backup/local/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
|
@ -610,7 +610,7 @@ function restore_personal_settings {
|
|||
if [ -d $USB_MOUNT/backup/personal ]; then
|
||||
for d in $USB_MOUNT/backup/personal/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $USB_MOUNT/backup/personal/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -663,7 +663,7 @@ function restore_email {
|
|||
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" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
|
|
|
@ -225,7 +225,7 @@ function restore_mutt_settings {
|
|||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/mutt/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/mutt/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -257,7 +257,7 @@ function restore_gpg {
|
|||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/gnupg/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/gnupg/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -290,7 +290,7 @@ function restore_procmail {
|
|||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/procmail/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/procmail/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -317,7 +317,7 @@ function restore_spamassassin {
|
|||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/spamassassin/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/spamassassin/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -363,7 +363,7 @@ function restore_ssh_keys {
|
|||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/ssh/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/ssh/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -390,7 +390,7 @@ function restore_user_config {
|
|||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/config/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/config/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -429,7 +429,7 @@ function restore_user_monkeysphere {
|
|||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/monkeysphere/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/monkeysphere/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -466,7 +466,7 @@ function restore_user_fin {
|
|||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/fin/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/fin/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -493,7 +493,7 @@ function restore_user_local {
|
|||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/local/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/local/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -561,7 +561,7 @@ function restore_personal_settings {
|
|||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/personal/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/personal/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
@ -608,7 +608,7 @@ function restore_email {
|
|||
fi
|
||||
for d in $SERVER_DIRECTORY/backup/mail/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -d $SERVER_DIRECTORY/backup/mail/$USERNAME ]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
|
|
|
@ -336,7 +336,7 @@ function send_monkeysphere_server_keys_to_users {
|
|||
monkeysphere_server_keys=$(monkeysphere-host show-key | grep $"OpenPGP fingerprint" | awk -F ' ' '{print $3}')
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ ! -d /home/$USERNAME/.monkeysphere ]; then
|
||||
mkdir /home/$USERNAME/.monkeysphere
|
||||
fi
|
||||
|
@ -952,7 +952,7 @@ function export_settings {
|
|||
function refresh_gpg_keys {
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
su -c 'gpg --refresh-keys' - $USERNAME
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -97,7 +97,7 @@ function create_syncthing_config {
|
|||
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
echo " <folder id=\"$USERNAME\" path=\"/home/$USERNAME/Sync/\" ro=\"false\" rescanIntervalS=\"60\" ignorePerms=\"false\" autoNormalize=\"true\">" >> $SYNCTHING_CONFIG_FILE
|
||||
# include any specified device IDs for this user
|
||||
if [ -f /home/$USERNAME/$SYNCTHING_USER_IDS_FILE ]; then
|
||||
|
@ -137,7 +137,7 @@ function create_syncthing_config {
|
|||
echo "" > $TEMP_IDS_FILE
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -f /home/$USERNAME/$SYNCTHING_USER_IDS_FILE ]; then
|
||||
while read -r line || [[ -n "$line" ]]; do
|
||||
line2="$(echo -e "${line}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
||||
|
@ -177,7 +177,7 @@ function create_syncthing_config {
|
|||
echo "" > $TEMP_IDS_FILE
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -f /home/$USERNAME/$SYNCTHING_USER_IDS_FILE ]; then
|
||||
while read -r line || [[ -n "$line" ]]; do
|
||||
line2="$(echo -e "${line}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
||||
|
@ -236,7 +236,7 @@ function create_syncthing_config {
|
|||
# This allows it to appear within the user control panel
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
echo "$SYNCTHING_ID" > /home/$USERNAME/.syncthing-server-id
|
||||
chown $USERNAME:$USERNAME /home/$USERNAME/.syncthing-server-id
|
||||
fi
|
||||
|
@ -257,7 +257,7 @@ function user_devices_changed {
|
|||
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
if [ -f /home/$USERNAME/$SYNCTHING_UPDATE_FILE ]; then
|
||||
CHANGED=1
|
||||
fi
|
||||
|
|
|
@ -275,7 +275,7 @@ function set_user_permissions {
|
|||
echo $"Setting permissions"
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
||||
if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue