Tidying
This commit is contained in:
parent
de1842e553
commit
d66370009d
|
@ -39,289 +39,206 @@ 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}')
|
||||
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
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
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"
|
||||
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
|
||||
}
|
||||
|
||||
function remove_blog {
|
||||
if ! grep -Fxq "install_blog" $COMPLETION_FILE; then
|
||||
return
|
||||
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
|
||||
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
|
||||
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
|
||||
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 {
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
chown -R www-data:www-data /var/www/$FULLBLOG_DOMAIN_NAME/htdocs
|
||||
chown -R www-data:www-data /var/www/$FULLBLOG_DOMAIN_NAME/htdocs
|
||||
|
||||
if [[ $ONION_ONLY == "no" ]]; then
|
||||
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
|
||||
else
|
||||
echo -n '' > /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
fi
|
||||
if [[ $ONION_ONLY == "no" ]]; then
|
||||
function_check nginx_http_redirect
|
||||
nginx_http_redirect $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 ' 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
|
||||
|
@ -331,6 +248,8 @@ function install_blog {
|
|||
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
|
||||
|
@ -397,95 +316,176 @@ function install_blog {
|
|||
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
|
||||
else
|
||||
echo -n '' > /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
|
||||
fi
|
||||
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_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
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
||||
# 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
|
||||
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
|
||||
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
|
||||
|
||||
# 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
|
||||
# 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 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
|
||||
function_check nginx_ensite
|
||||
nginx_ensite $FULLBLOG_DOMAIN_NAME
|
||||
|
||||
# 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
|
||||
FULLBLOG_ONION_HOSTNAME=$(add_onion_service blog 80 ${FULLBLOG_ONION_PORT})
|
||||
|
||||
function_check nginx_ensite
|
||||
nginx_ensite $FULLBLOG_DOMAIN_NAME
|
||||
systemctl restart php5-fpm
|
||||
systemctl restart nginx
|
||||
|
||||
FULLBLOG_ONION_HOSTNAME=$(add_onion_service blog 80 ${FULLBLOG_ONION_PORT})
|
||||
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
|
||||
|
||||
systemctl restart php5-fpm
|
||||
systemctl restart nginx
|
||||
function_check add_ddns_domain
|
||||
add_ddns_domain $FULLBLOG_DOMAIN_NAME
|
||||
|
||||
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 domain:" $COMPLETION_FILE; then
|
||||
echo "Blog domain:$FULLBLOG_DOMAIN_NAME" >> $COMPLETION_FILE
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
echo 'install_blog' >> $COMPLETION_FILE
|
||||
echo 'install_blog' >> $COMPLETION_FILE
|
||||
}
|
||||
|
||||
# NOTE: deliberately no exit 0
|
||||
|
|
Loading…
Reference in New Issue