freedombone/src/freedombone-app-ghost

604 lines
21 KiB
Bash
Executable File

#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Ghost blog
#
# License
# =======
#
# Copyright (C) 2016-2018 Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
VARIANTS="full full-vim writer"
IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1
GHOST_VERSION=1.19.0
GHOST_DOMAIN_NAME=
GHOST_CODE=
GHOST_ONION_PORT=8104
GHOST_PORT=2368
ghost_variables=(GHOST_DOMAIN_NAME
GHOST_CODE
GHOST_ADMIN_PASSWORD
ONION_ONLY
DDNS_PROVIDER
MY_USERNAME)
function ghost_bust {
# kill the started ghost process
kill_pid=$(pgrep "ghost run" | head -n 1)
kill -9 "$kill_pid"
kill_pid=$(pgrep "ghost" | head -n 1)
kill -9 "$kill_pid"
kill_pid=$(pgrep "ghost" | head -n 1)
kill -9 "$kill_pid"
}
function logging_on_ghost {
echo -n ''
}
function logging_off_ghost {
echo -n ''
}
function ghost_replace_jquery {
curr_domain="https://$GHOST_DOMAIN_NAME"
if [[ "$ONION_ONLY" != 'no' ]]; then
curr_domain="http://$GHOST_ONION_HOSTNAME"
fi
sed -i "s|src=\"https://code.jquery.com/jquery-.*|src=\"$curr_domain/jquery-${jquery_version}.js\"|g" current/content/themes/casper/default.hbs
sed -i "s|src=\"https://code.jquery.com/jquery-.*|src=\"$curr_domain/jquery-${jquery_version}.js\"></script>|g" current/node_modules/gscan/app/tpl/layouts/default.hbs
sed -i "s|http://code.jquery.com/jquery.js|$curr_domain/jquery-${jquery_version}.js|g" current/node_modules/jsdom/README.md
sed -i "s|https://code.jquery.com/jquery.js|$curr_domain/jquery-${jquery_version}.js|g" current/node_modules/jsdom/README.md
cd "/var/www/${GHOST_DOMAIN_NAME}/htdocs/current" || exit 3468368
find ./ -type f -exec sed -i -e "s|https://code.jquery.com|$curr_domain|g" {} \;
find ./ -type f -exec sed -i -e "s|http://code.jquery.com|$curr_domain|g" {} \;
}
function ghost_rss_button {
# remove feedly -aaargh!
sed -i 's|http://cloud.feedly.com/#subscription/feed/{{@blog.url}}/rss/|{{@blog.url}}/rss/|g' /var/www/$GHOST_DOMAIN_NAME/htdocs/versions/${GHOST_VERSION}/content/themes/casper/partials/site-nav.hbs
sed -i 's|http://cloud.feedly.com/#subscription/feed/{{url absolute="true"}}/rss/|{{url absolute="true"}}rss/|g' /var/www/$GHOST_DOMAIN_NAME/htdocs/versions/${GHOST_VERSION}/content/themes/casper/author.hbs
}
function ghost_remove_offsite_links {
curr_domain="$GHOST_DOMAIN_NAME"
if [[ "$ONION_ONLY" != 'no' ]]; then
curr_domain="$GHOST_ONION_HOSTNAME"
fi
ghost_rss_button
# remove google font links
cd "/var/www/$GHOST_DOMAIN_NAME/htdocs/current" || exit 246872424
find ./ -type f -exec sed -i -e "s/fonts.googleapis.com/$curr_domain/g" {} \;
# copy jquery locally
previous_jquery_version='1.12.0'
jquery_version='1.12.4'
if [ ! -f /var/www/$GHOST_DOMAIN_NAME/htdocs/jquery-${jquery_version}.js ]; then
cd "/var/www/$GHOST_DOMAIN_NAME/htdocs" || exit 3468746824
wget https://code.jquery.com/jquery-${jquery_version}.js
jquery_hash=$(sha256sum jquery-${jquery_version}.js | awk -F ' ' '{print $1}')
if [[ "$jquery_hash" != '430f36f9b5f21aae8cc9dca6a81c4d3d84da5175eaedcf2fdc2c226302cb3575' ]]; then
echo $'Unexpected jquery hash value'
exit 258442
fi
fi
ghost_replace_jquery
previous_jquery_version='1.11.3'
ghost_replace_jquery
}
function ghost_replace_proprietary_services {
replace_file="$1"
sed -i 's|Twitter Profile|GNU Social Profile|g' "$replace_file"
sed -i 's|Twitter profile|GNU Social Profile|g' "$replace_file"
sed -i 's|Twitter Username|GNU Social Username|g' "$replace_file"
sed -i 's|twitter.com|quitter.se|g' "$replace_file"
sed -i 's|Facebook Page|Hubzilla Channel|g' "$replace_file"
sed -i 's|Facebook Profile|Hubzilla Channel|g' "$replace_file"
sed -i 's|Facebook profile|Hubzilla Channel|g' "$replace_file"
sed -i 's|www.facebook.com/username|hubzilladomain/username|g' "$replace_file"
sed -i 's|www.facebook.com/ghost|hubzilladomain/username|g' "$replace_file"
sed -i 's|www.facebook.com/testuser|hubzilladomain/username|g' "$replace_file"
sed -i 's|www.facebook.com/testing|hubzilladomain/username|g' "$replace_file"
sed -i 's|www.facebook.com/test|hubzilladomain/username|g' "$replace_file"
sed -i 's|www.facebook.com/yourUsername|hubzilladomain/username|g' "$replace_file"
sed -i 's|www.facebook.com/yourPage|hubzilladomain/username|g' "$replace_file"
sed -i 's|Facebook Username|Hubzilla Channel|g' "$replace_file"
sed -i 's|www.facebook.com|hubzilladomain|g' "$replace_file"
sed -i 's|facebook value|hubzilla value|g' "$replace_file"
sed -i '/<section class="share">/,/<\/section>/d' "$replace_file"
}
function ghost_replace_services {
ghost_replace_proprietary_services /var/www/${GHOST_DOMAIN_NAME}/htdocs/content/themes/casper/post.hbs
}
function remove_user_ghost {
remove_username="$1"
}
function add_user_ghost {
if [[ $(app_is_installed ghost) == "0" ]]; then
echo '0'
return
fi
new_username="$1"
new_user_password="$2"
echo '0'
}
function install_interactive_ghost {
if [ ! "$ONION_ONLY" ]; then
ONION_ONLY='no'
fi
if [[ $ONION_ONLY != "no" ]]; then
GHOST_DOMAIN_NAME='ghost.local'
write_config_param "GHOST_DOMAIN_NAME" "$GHOST_DOMAIN_NAME"
else
function_check interactive_site_details
interactive_site_details "ghost" "GHOST_DOMAIN_NAME" "GHOST_CODE"
fi
APP_INSTALLED=1
}
function change_password_ghost {
#GHOST_USERNAME="$1"
GHOST_PASSWORD="$2"
if [ ${#GHOST_PASSWORD} -lt 8 ]; then
echo $'Ghost password is too short'
return
fi
#"${PROJECT_NAME}-pass" -u "$GHOST_USERNAME" -a ghost -p "$GHOST_PASSWORD"
}
function reconfigure_ghost {
echo -n ''
}
function upgrade_ghost {
CURR_GHOST_VERSION=$(get_completion_param "ghost version")
if [[ "${CURR_GHOST_VERSION}" == "${GHOST_VERSION}" ]]; then
return
fi
read_config_param GHOST_DOMAIN_NAME
if [ ! -d /var/www/$GHOST_DOMAIN_NAME/htdocs ]; then
return
fi
systemctl stop ghost
ghost_bust
cd "/var/www/$GHOST_DOMAIN_NAME/htdocs" || exit 3468463
npm i -g ghost-cli
/usr/local/bin/ghost update &
sleep 200
ghost_bust
ghost_replace_services
ghost_remove_offsite_links
chown root:root /usr/local/bin/ghost
chown -R root:root /usr/local/lib
chown -R ghost: /var/www/${GHOST_DOMAIN_NAME}/htdocs
systemctl restart ghost
sed -i "s|ghost version.*|ghost version:${GHOST_VERSION}|g" "${COMPLETION_FILE}"
}
function backup_local_ghost {
GHOST_DOMAIN_NAME='ghost.local'
if grep -q "ghost domain" "$COMPLETION_FILE"; then
GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
fi
suspend_site "${GHOST_DOMAIN_NAME}"
systemctl stop ghost
ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
if [ -d "$ghost_path" ]; then
backup_directory_to_usb "$ghost_path" ghostcontent
fi
ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs/current/content
if [ -d "$ghost_path" ]; then
backup_directory_to_usb "$ghost_path" ghostcurrent
fi
systemctl start ghost
restart_site
}
function restore_local_ghost {
GHOST_DOMAIN_NAME='ghost.local'
if grep -q "ghost domain" "$COMPLETION_FILE"; then
GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
fi
if [ "$GHOST_DOMAIN_NAME" ]; then
suspend_site "${GHOST_DOMAIN_NAME}"
systemctl stop ghost
temp_restore_dir=/root/tempghostcontent
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir ghostcontent
if [ -d $temp_restore_dir ]; then
if [ -d "$temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content" ]; then
cp -r "$temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/*" "/var/www/$GHOST_DOMAIN_NAME/htdocs/content/"
else
if [ ! -d "/var/www/$GHOST_DOMAIN_NAME/htdocs/content" ]; then
mkdir "/var/www/$GHOST_DOMAIN_NAME/htdocs/content"
fi
cp -r $temp_restore_dir/* "/var/www/$GHOST_DOMAIN_NAME/htdocs/content/"
fi
chown -R ghost:ghost "/var/www/$GHOST_DOMAIN_NAME/htdocs/content"
rm -rf $temp_restore_dir
fi
temp_restore_dir=/root/tempghostcurrent
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir ghostcurrent
if [ -d $temp_restore_dir ]; then
if [ -d "$temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content" ]; then
cp -r "$temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/*" "/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/"
else
if [ ! -d "/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content" ]; then
mkdir -p "/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content"
fi
cp -r $temp_restore_dir/* "/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/"
fi
chown -R ghost:ghost "/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content"
rm -rf $temp_restore_dir
fi
systemctl start ghost
restart_site
fi
}
function backup_remote_ghost {
GHOST_DOMAIN_NAME='ghost.local'
if grep -q "ghost domain" "$COMPLETION_FILE"; then
GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
fi
suspend_site "${GHOST_DOMAIN_NAME}"
temp_backup_dir=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
if [ -d "$temp_backup_dir" ]; then
backup_directory_to_friend "$temp_backup_dir" ghostcontent
else
restart_site
echo $"Ghost domain specified but not found in /var/www/${GHOST_DOMAIN_NAME}"
exit 2578
fi
temp_backup_dir=/var/www/${GHOST_DOMAIN_NAME}/htdocs/current/content
if [ -d "$temp_backup_dir" ]; then
backup_directory_to_friend "$temp_backup_dir" ghostcurrent
else
restart_site
echo $"Ghost domain specified but not found in $temp_backup_dir"
exit 78353
fi
restart_site
}
function restore_remote_ghost {
GHOST_DOMAIN_NAME='ghost.local'
if grep -q "ghost domain" "$COMPLETION_FILE"; then
GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
fi
suspend_site "${GHOST_DOMAIN_NAME}"
systemctl stop ghost
temp_restore_dir=/root/tempghostcontent
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir ghostcontent
if [ -d $temp_restore_dir ]; then
if [ -d "$temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content" ]; then
cp -r "$temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/*" "/var/www/$GHOST_DOMAIN_NAME/htdocs/content/"
else
if [ ! -d "/var/www/$GHOST_DOMAIN_NAME/htdocs/content" ]; then
mkdir "/var/www/$GHOST_DOMAIN_NAME/htdocs/content"
fi
cp -r $temp_restore_dir/* "/var/www/$GHOST_DOMAIN_NAME/htdocs/content/"
fi
chown -R ghost: "/var/www/$GHOST_DOMAIN_NAME/htdocs"
rm -rf $temp_restore_dir
fi
temp_restore_dir=/root/tempghostcurrent
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir ghostcurrent
if [ -d $temp_restore_dir ]; then
if [ -d "$temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content" ]; then
cp -r "$temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/*" "/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/"
else
if [ ! -d "/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content" ]; then
mkdir -p "/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content"
fi
cp -r $temp_restore_dir/* "/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/"
fi
chown -R ghost: "/var/www/$GHOST_DOMAIN_NAME/htdocs"
rm -rf $temp_restore_dir
fi
systemctl start ghost
restart_site
}
function remove_ghost {
if [ ${#GHOST_DOMAIN_NAME} -eq 0 ]; then
return
fi
systemctl stop ghost
systemctl disable ghost
rm /etc/systemd/system/ghost.service
systemctl daemon-reload
npm uninstall -g ghost-cli
function_check remove_nodejs
remove_nodejs ghost
read_config_param "GHOST_DOMAIN_NAME"
nginx_dissite "$GHOST_DOMAIN_NAME"
remove_certs "${GHOST_DOMAIN_NAME}"
if [ -f "/etc/nginx/sites-available/$GHOST_DOMAIN_NAME" ]; then
rm -f "/etc/nginx/sites-available/$GHOST_DOMAIN_NAME"
fi
if [ -d "/var/www/$GHOST_DOMAIN_NAME" ]; then
rm -rf "/var/www/$GHOST_DOMAIN_NAME"
fi
remove_config_param GHOST_DOMAIN_NAME
remove_config_param GHOST_CODE
function_check remove_onion_service
remove_onion_service ghost ${GHOST_ONION_PORT}
remove_completion_param "install_ghost"
sed -i '/Ghost/d' "$COMPLETION_FILE"
sed -i '/ghost/d' "$COMPLETION_FILE"
groupdel -f ghost
userdel -r ghost
function_check remove_ddns_domain
remove_ddns_domain "$GHOST_DOMAIN_NAME"
}
function install_ghost {
check_ram_availability 900
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
if [ ! "$GHOST_DOMAIN_NAME" ]; then
echo $'The ghost domain name was not specified'
exit 5062
fi
# for the avatar changing command
apt-get -yq install unzip wget
if [ ! -d "/var/www/$GHOST_DOMAIN_NAME/htdocs" ]; then
mkdir -p "/var/www/$GHOST_DOMAIN_NAME/htdocs"
fi
cd "/var/www/$GHOST_DOMAIN_NAME/htdocs" || exit 26422842
function_check install_nodejs
install_nodejs ghost
# now install ghost itself
npm install -g ghost-cli@latest
if [ ! -f /usr/local/bin/ghost ]; then
echo $'ghost was not installed'
exit 738539
fi
GHOST_ONION_HOSTNAME=$(add_onion_service ghost 80 ${GHOST_ONION_PORT})
npm install -g yarn
yarn install --no-emoji --no-progress
yarn cache clean
adduser --system --home="/var/www/${GHOST_DOMAIN_NAME}/htdocs/" --group ghost
rm -rf "/var/www/$GHOST_DOMAIN_NAME/htdocs/*"
printf 'y' | ghost install ${GHOST_VERSION} --user ghost --db=sqlite3 --port ${GHOST_PORT} --verbose
if [ ! -d "/var/www/$GHOST_DOMAIN_NAME/htdocs/versions" ]; then
echo $'versions directory was not found'
exit 782523462
fi
if [ ! -d "/var/www/$GHOST_DOMAIN_NAME/htdocs/content" ]; then
echo $'content directory was not found'
exit 68352682
fi
npm install -g knex-migrator
if [ ! -f "/var/www/$GHOST_DOMAIN_NAME/htdocs/versions/${GHOST_VERSION}/MigratorConfig.js" ]; then
echo $'MigratorConfig.js was not found'
exit 62783538
fi
cp "/var/www/$GHOST_DOMAIN_NAME/htdocs/versions/${GHOST_VERSION}/MigratorConfig.js" "/var/www/$GHOST_DOMAIN_NAME/htdocs"
chown -R ghost: "/var/www/$GHOST_DOMAIN_NAME/htdocs"
cd "/var/www/$GHOST_DOMAIN_NAME/htdocs/current" || exit 783452464
knex-migrator init
ghost_bust
echo '{' > "/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.development.json"
if [[ "$ONION_ONLY" == 'no' ]]; then
# NOTE: url must be http, not https
echo " \"url\": \"http://${GHOST_DOMAIN_NAME}\"," >> "/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.development.json"
else
echo " \"url\": \"http://${GHOST_ONION_HOSTNAME}\"," >> "/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.development.json"
fi
{ echo ' "paths": {';
echo " \"contentPath\": \"/var/www/${GHOST_DOMAIN_NAME}/htdocs/content\"";
echo ' }';
echo '}'; } >> "/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.development.json"
{ echo '[Unit]';
echo 'Description=Ghost Blog';
echo 'After=syslog.target';
echo 'After=network.target';
echo '';
echo '[Service]';
echo 'Type=simple';
echo 'User=ghost';
echo 'Group=ghost';
echo "WorkingDirectory=/var/www/${GHOST_DOMAIN_NAME}/htdocs";
echo "ExecStart=/usr/local/bin/ghost run -D";
echo "ExecStop=/usr/local/bin/ghost stop";
echo "ExecRestart=/usr/local/bin/ghost restart";
echo 'Restart=always';
echo 'RestartSec=60';
echo "Environment=NODE_ENV=development PORT=${GHOST_PORT}";
echo '';
echo '[Install]';
echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/ghost.service
ghost_remove_offsite_links
chown -R ghost: "/var/www/${GHOST_DOMAIN_NAME}/htdocs"
systemctl enable ghost
systemctl daemon-reload
systemctl start ghost
if [[ ${ONION_ONLY} == "no" ]]; then
function_check nginx_http_redirect
nginx_http_redirect "${GHOST_DOMAIN_NAME}"
{ echo 'server {';
echo ' listen 443 ssl;';
echo ' #listen [::]:443 ssl;';
echo " root /var/www/${GHOST_DOMAIN_NAME}/htdocs;";
echo " server_name ${GHOST_DOMAIN_NAME};";
echo ' access_log /dev/null;';
echo " error_log /dev/null;";
echo ''; } >> "/etc/nginx/sites-available/${GHOST_DOMAIN_NAME}"
function_check nginx_ssl
nginx_ssl "${GHOST_DOMAIN_NAME}"
function_check nginx_disable_sniffing
nginx_disable_sniffing "${GHOST_DOMAIN_NAME}"
{ echo ' add_header Strict-Transport-Security max-age=0;';
echo '';
echo ' location / {'; } >> "/etc/nginx/sites-available/${GHOST_DOMAIN_NAME}"
function_check nginx_limits
nginx_limits "${GHOST_DOMAIN_NAME}" '10G'
{ echo " proxy_pass http://localhost:${GHOST_PORT};";
echo ' }';
echo '';
echo ' fastcgi_buffers 64 4K;';
echo '';
echo ' error_page 403 /core/templates/403.php;';
echo ' error_page 404 /core/templates/404.php;';
echo '';
echo ' location = /robots.txt {';
echo ' allow all;';
echo ' log_not_found off;';
echo ' access_log /dev/null;';
echo ' }';
echo '}';
echo ''; } >> "/etc/nginx/sites-available/${GHOST_DOMAIN_NAME}"
else
echo -n '' > "/etc/nginx/sites-available/${GHOST_DOMAIN_NAME}"
fi
{ echo 'server {';
echo " listen 127.0.0.1:${GHOST_ONION_PORT} default_server;";
echo " root /var/www/$GHOST_DOMAIN_NAME/htdocs;";
echo " server_name $GHOST_ONION_HOSTNAME;";
echo ' access_log /dev/null;';
echo " error_log /dev/null;";
echo ''; } >> "/etc/nginx/sites-available/${GHOST_DOMAIN_NAME}"
function_check nginx_disable_sniffing
nginx_disable_sniffing "${GHOST_DOMAIN_NAME}"
{ echo ' add_header Strict-Transport-Security max-age=0;';
echo '';
echo ' location / {'; } >> "/etc/nginx/sites-available/${GHOST_DOMAIN_NAME}"
function_check nginx_limits
nginx_limits "${GHOST_DOMAIN_NAME}" '10G'
{ echo " proxy_pass http://localhost:${GHOST_PORT};";
echo ' }';
echo '';
echo ' fastcgi_buffers 64 4K;';
echo '';
echo ' error_page 403 /core/templates/403.php;';
echo ' error_page 404 /core/templates/404.php;';
echo '';
echo ' location = /robots.txt {';
echo ' allow all;';
echo ' log_not_found off;';
echo ' access_log /dev/null;';
echo ' }';
echo '}'; } >> "/etc/nginx/sites-available/${GHOST_DOMAIN_NAME}"
function_check create_site_certificate
create_site_certificate "$GHOST_DOMAIN_NAME" 'yes'
ghost_replace_services
function_check nginx_ensite
nginx_ensite "$GHOST_DOMAIN_NAME"
systemctl restart nginx
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a ghost -p "$GHOST_ADMIN_PASSWORD"
function_check add_ddns_domain
add_ddns_domain "$GHOST_DOMAIN_NAME"
chown root:root /usr/local/bin/ghost
chown -R root:root /usr/local/lib
chown -R ghost: "/var/www/${GHOST_DOMAIN_NAME}/htdocs"
set_completion_param "ghost domain" "$GHOST_DOMAIN_NAME"
if ! grep -q "ghost version:" "${COMPLETION_FILE}"; then
echo "ghost version:${GHOST_VERSION}" >> "${COMPLETION_FILE}"
else
sed -i "s|ghost version.*|ghost version:${GHOST_VERSION}|g" "${COMPLETION_FILE}"
fi
APP_INSTALLED=1
}
# NOTE: deliberately no exit 0