Fix fedwiki

This commit is contained in:
Bob Mottram 2018-03-30 17:30:40 +01:00
parent 1da89f4273
commit e789ed5a63
2 changed files with 56 additions and 36 deletions

View File

@ -55,50 +55,50 @@ fedwiki_variables=(FEDWIKI_DOMAIN_NAME
function fedwiki_remove_bad_links {
if [[ $ONION_ONLY == 'no' ]]; then
sed -i "s|link[href='https://maxcdn.bootstrapcdn.com.*|link[href='https://${FEDWIKI_DOMAIN_NAME}/fonts-font-awesome/css/font-awesome.min.css']\").length) {|g" /usr/local/lib/node_modules/wiki/node_modules/wiki-security-friends/client/security.js
sed -i "s|link\\[href='https://maxcdn.bootstrapcdn.com.*|link\\[href='https://${FEDWIKI_DOMAIN_NAME}/fonts-font-awesome/css/font-awesome.min.css']\").length) {|g" /var/lib/wiki/node_modules/wiki-security-friends/client/security.js
sed -i "s|\$('<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com.*|\$('<link rel=\"stylesheet\" href=\"https://${FEDWIKI_DOMAIN_NAME}/fonts-font-awesome/css/font-awesome.min.css\">').appendTo(\"head\");|g" /usr/local/lib/node_modules/wiki/node_modules/wiki-security-friends/client/security.js
sed -i "s|\$('<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com.*|\$('<link rel=\"stylesheet\" href=\"https://${FEDWIKI_DOMAIN_NAME}/fonts-font-awesome/css/font-awesome.min.css\">').appendTo(\"head\");|g" /var/lib/wiki/node_modules/wiki-security-friends/client/security.js
else
FEDWIKI_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_fedwiki/hostname)
sed -i "s|link[href='https://maxcdn.bootstrapcdn.com.*|link[href='http://${FEDWIKI_ONION_HOSTNAME}/fonts-font-awesome/css/font-awesome.min.css']\").length) {|g" /usr/local/lib/node_modules/wiki/node_modules/wiki-security-friends/client/security.js
sed -i "s|link\\[href='https://maxcdn.bootstrapcdn.com.*|link\\[href='http://${FEDWIKI_ONION_HOSTNAME}/fonts-font-awesome/css/font-awesome.min.css']\").length) {|g" /var/lib/wiki/node_modules/wiki-security-friends/client/security.js
sed -i "s|\$('<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com.*|\$('<link rel=\"stylesheet\" href=\"http://${FEDWIKI_ONION_HOSTNAME}/fonts-font-awesome/css/font-awesome.min.css\">').appendTo(\"head\");|g" /usr/local/lib/node_modules/wiki/node_modules/wiki-security-friends/client/security.js
sed -i "s|\$('<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com.*|\$('<link rel=\"stylesheet\" href=\"http://${FEDWIKI_ONION_HOSTNAME}/fonts-font-awesome/css/font-awesome.min.css\">').appendTo(\"head\");|g" /var/lib/wiki/node_modules/wiki-security-friends/client/security.js
fi
if [ -f /usr/local/lib/node_modules/wiki/node_modules/localforage/docs/theme/style.css ]; then
sed -i '/googleapi/d' /usr/local/lib/node_modules/wiki/node_modules/localforage/docs/theme/style.css
if [ -f /var/lib/wiki/node_modules/localforage/docs/theme/style.css ]; then
sed -i '/googleapi/d' /var/lib/wiki/node_modules/localforage/docs/theme/style.css
fi
if [ -f /usr/local/lib/node_modules/wiki/node_modules/wiki-security-passportjs/views/addAlternativeDialog.html ]; then
sed -i '/googleapi/d' /usr/local/lib/node_modules/wiki/node_modules/wiki-security-passportjs/views/addAlternativeDialog.html
if [ -f /var/lib/wiki/node_modules/wiki-security-passportjs/views/addAlternativeDialog.html ]; then
sed -i '/googleapi/d' /var/lib/wiki/node_modules/wiki-security-passportjs/views/addAlternativeDialog.html
fi
if [ -f /usr/local/lib/node_modules/wiki/node_modules/wiki-security-passportjs/views/done.html ]; then
sed -i '/googleapi/d' /usr/local/lib/node_modules/wiki/node_modules/wiki-security-passportjs/views/done.html
if [ -f /var/lib/wiki/node_modules/wiki-security-passportjs/views/done.html ]; then
sed -i '/googleapi/d' /var/lib/wiki/node_modules/wiki-security-passportjs/views/done.html
fi
if [ -f /usr/local/lib/node_modules/wiki/node_modules/wiki-security-passportjs/views/personaDialog.html ]; then
sed -i '/googleapi/d' /usr/local/lib/node_modules/wiki/node_modules/wiki-security-passportjs/views/personaDialog.html
if [ -f /var/lib/wiki/node_modules/wiki-security-passportjs/views/personaDialog.html ]; then
sed -i '/googleapi/d' /var/lib/wiki/node_modules/wiki-security-passportjs/views/personaDialog.html
fi
if [ -f /usr/local/lib/node_modules/wiki/node_modules/wiki-security-passportjs/views/securityDialog.html ]; then
sed -i '/googleapi/d' /usr/local/lib/node_modules/wiki/node_modules/wiki-security-passportjs/views/securityDialog.html
if [ -f /var/lib/wiki/node_modules/wiki-security-passportjs/views/securityDialog.html ]; then
sed -i '/googleapi/d' /var/lib/wiki/node_modules/wiki-security-passportjs/views/securityDialog.html
fi
if [ -d /usr/local/lib/node_modules/wiki/node_modules/passport-google-oauth20 ]; then
rm -rf /usr/local/lib/node_modules/wiki/node_modules/passport-google-oauth20
if [ -d /var/lib/wiki/node_modules/passport-google-oauth20 ]; then
rm -rf /var/lib/wiki/node_modules/passport-google-oauth20
fi
if [ -d /usr/local/lib/node_modules/wiki/node_modules/passport-oauth2 ]; then
rm -rf /usr/local/lib/node_modules/wiki/node_modules/passport-oauth2
if [ -d /var/lib/wiki/node_modules/passport-oauth2 ]; then
rm -rf /var/lib/wiki/node_modules/passport-oauth2
fi
if [ -d /usr/local/lib/node_modules/wiki/node_modules/passport-twitter ]; then
rm -rf /usr/local/lib/node_modules/wiki/node_modules/passport-twitter
if [ -d /var/lib/wiki/node_modules/passport-twitter ]; then
rm -rf /var/lib/wiki/node_modules/passport-twitter
fi
if [ -d /usr/local/lib/node_modules/wiki/node_modules/passport-github ]; then
rm -rf /usr/local/lib/node_modules/wiki/node_modules/passport-github
if [ -d /var/lib/wiki/node_modules/passport-github ]; then
rm -rf /var/lib/wiki/node_modules/passport-github
fi
}
@ -168,7 +168,13 @@ function upgrade_fedwiki {
systemctl stop fedwiki
npm upgrade -g wiki@$FEDWIKI_VERSION
cp -r /root/.npm-global/lib/node_modules/wiki/* /var/lib/wiki/
cp /root/.npm-global/bin/wiki /var/lib/wiki/wiki
chown -R fedwiki:fedwiki /var/lib/wiki
fedwiki_remove_bad_links
chown -R fedwiki:fedwiki $FEDWIKI_DATA
systemctl start fedwiki
@ -302,6 +308,9 @@ function remove_fedwiki {
if [ -d "/var/www/$FEDWIKI_DOMAIN_NAME" ]; then
rm -rf "/var/www/$FEDWIKI_DOMAIN_NAME"
fi
if [ -d /var/lib/wiki ]; then
rm -rf /var/lib/wiki
fi
remove_config_param FEDWIKI_DOMAIN_NAME
remove_config_param FEDWIKI_CODE
function_check remove_onion_service
@ -437,13 +446,13 @@ function install_fedwiki {
exit 783533
fi
if [ ! -f /usr/local/bin/wiki ]; then
if [ ! -f /root/.npm-global/bin/wiki ]; then
echo $'wiki was not installed'
exit 5293524
fi
if [ ! -d /usr/local/lib/node_modules/wiki ]; then
echo $'wiki directory not found /usr/local/lib/node_modules/wiki'
if [ ! -d /root/.npm-global/lib/node_modules/wiki ]; then
echo $'wiki directory not found /root/.npm-global/lib/node_modules/wiki'
exit 6285324
fi
@ -453,6 +462,10 @@ function install_fedwiki {
FEDWIKI_COOKIE="$(create_password 20)"
fi
cp -r /root/.npm-global/lib/node_modules/wiki /var/lib
cp /root/.npm-global/bin/wiki /var/lib/wiki
chown -R fedwiki:fedwiki /var/lib/wiki
{ echo '[Unit]';
echo 'Description=Fedwiki federated wiki';
echo 'After=syslog.target';
@ -461,8 +474,8 @@ function install_fedwiki {
echo '[Service]';
echo 'User=fedwiki';
echo 'Group=fedwiki';
echo "WorkingDirectory=/usr/local/lib/node_modules/wiki";
echo "ExecStart=/usr/local/bin/wiki --security_type friends --session_duration 7 --data $FEDWIKI_DATA -p $FEDWIKI_PORT --cookieSecret '${FEDWIKI_COOKIE}'";
echo "WorkingDirectory=/var/lib/wiki";
echo "ExecStart=/var/lib/wiki/wiki --security_type friends --session_duration 7 --data $FEDWIKI_DATA -p $FEDWIKI_PORT --cookieSecret '${FEDWIKI_COOKIE}'";
echo 'StandardOutput=syslog';
echo 'StandardError=syslog';
echo 'SyslogIdentifier=fedwiki';

View File

@ -209,14 +209,14 @@ function upgrade_ghost {
cd "/var/www/$GHOST_DOMAIN_NAME/htdocs" || exit 3468463
npm i -g ghost-cli
/usr/local/bin/ghost update &
/root/.npm-global/bin/ghost update &
sleep 200
ghost_bust
ghost_replace_services
ghost_remove_offsite_links
chown root:root /usr/local/bin/ghost
chown root:root /root/.npm-global/bin/ghost
chown -R root:root /usr/local/lib
chown -R ghost: /var/www/${GHOST_DOMAIN_NAME}/htdocs
systemctl restart ghost
@ -429,8 +429,8 @@ function install_ghost {
install_nodejs ghost
# now install ghost itself
npm install -g ghost-cli@latest
if [ ! -f /usr/local/bin/ghost ]; then
npm install -g ghost-cli@1.6.0
if [ ! -f /root/.npm-global/bin/ghost ]; then
echo $'ghost was not installed'
exit 738539
fi
@ -438,11 +438,18 @@ function install_ghost {
GHOST_ONION_HOSTNAME=$(add_onion_service ghost 80 ${GHOST_ONION_PORT})
npm install -g yarn
if [ ! -f /root/.npm-global/bin/yarn ]; then
echo $'yarn was not installed'
exit 2648246
fi
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
echo "PATH=$PATH" > setup_ghost
echo "ghost install ${GHOST_VERSION} --no-prompt --db=sqlite3 --port ${GHOST_PORT} --verbose" >> setup_ghost
chmod +x setup_ghost
su -c "setup_ghost" - ghost
if [ ! -d "/var/www/$GHOST_DOMAIN_NAME/htdocs/versions" ]; then
echo $'versions directory was not found'
@ -487,9 +494,9 @@ function install_ghost {
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 "ExecStart=/root/.npm-global/bin/ghost run -D";
echo "ExecStop=/root/.npm-global/bin/ghost stop";
echo "ExecRestart=/root/.npm-global/bin/ghost restart";
echo 'Restart=always';
echo 'RestartSec=60';
echo "Environment=NODE_ENV=development PORT=${GHOST_PORT}";
@ -587,7 +594,7 @@ function install_ghost {
function_check add_ddns_domain
add_ddns_domain "$GHOST_DOMAIN_NAME"
chown root:root /usr/local/bin/ghost
chown root:root /root/.npm-global/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"