Use npm for wiki install #69

This commit is contained in:
Bob Mottram 2017-12-18 12:25:30 +00:00
parent 0b8642e683
commit 396ac49f00
2 changed files with 22 additions and 42 deletions

View File

@ -35,11 +35,9 @@ SHOW_ON_ABOUT=1
FEDWIKI_DOMAIN_NAME= FEDWIKI_DOMAIN_NAME=
FEDWIKI_CODE= FEDWIKI_CODE=
FEDWIKI_REPO="https://github.com/fedwiki/wiki" FEDWIKI_VERSION='0.13.0'
FEDWIKI_COMMIT='8fba3bb5c18b53b0c07fd2f2af10058b0d1bd253'
FEDWIKI_ONION_PORT=8131 FEDWIKI_ONION_PORT=8131
FEDWIKI_PORT=3053 FEDWIKI_PORT=3053
FEDWIKI_DIR=/etc/fedwiki
FEDWIKI_DATA=/var/lib/fedwiki FEDWIKI_DATA=/var/lib/fedwiki
fedwiki_variables=(FEDWIKI_DOMAIN_NAME fedwiki_variables=(FEDWIKI_DOMAIN_NAME
@ -104,22 +102,17 @@ function reconfigure_fedwiki {
} }
function upgrade_fedwiki { function upgrade_fedwiki {
CURR_FEDWIKI_COMMIT=$(get_completion_param "fedwiki commit") CURR_FEDWIKI_VERSION=$(get_completion_param "fedwiki version")
if [[ "$CURR_FEDWIKI_COMMIT" == "$FEDWIKI_COMMIT" ]]; then if [[ "$CURR_FEDWIKI_VERSION" == "$FEDWIKI_VERSION" ]]; then
return return
fi fi
read_config_param FEDWIKI_DOMAIN_NAME
systemctl stop fedwiki systemctl stop fedwiki
cd $FEDWIKI_DIR npm upgrade -g wiki@$FEDWIKI_VERSION
function_check set_repo_commit
set_repo_commit $FEDWIKI_DIR "fedwiki commit" "$FEDWIKI_COMMIT" $FEDWIKI_REPO
npm run upgrade-fedwiki
chown -R fedwiki:fedwiki $FEDWIKI_DIR
chown -R fedwiki:fedwiki $FEDWIKI_DATA chown -R fedwiki:fedwiki $FEDWIKI_DATA
systemctl start fedwiki systemctl start fedwiki
set_completion_param "fedwiki version" "$FEDWIKI_VERSION"
} }
function backup_local_fedwiki { function backup_local_fedwiki {
@ -224,6 +217,8 @@ function remove_fedwiki {
rm /etc/systemd/system/fedwiki.service rm /etc/systemd/system/fedwiki.service
systemctl daemon-reload systemctl daemon-reload
npm uninstall -g wiki
function_check remove_nodejs function_check remove_nodejs
remove_nodejs fedwiki remove_nodejs fedwiki
@ -246,9 +241,6 @@ function remove_fedwiki {
groupdel -f fedwiki groupdel -f fedwiki
userdel -r fedwiki userdel -r fedwiki
if [ -d $FEDWIKI_DIR ]; then
rm -rf $FEDWIKI_DIR
fi
if [ -d $FEDWIKI_DATA ]; then if [ -d $FEDWIKI_DATA ]; then
rm -rf $FEDWIKI_DATA rm -rf $FEDWIKI_DATA
fi fi
@ -326,43 +318,32 @@ function install_fedwiki {
exit 893635 exit 893635
fi fi
#apt-get -yq install ffmpeg
if [ ! -d /var/www/$FEDWIKI_DOMAIN_NAME/htdocs ]; then if [ ! -d /var/www/$FEDWIKI_DOMAIN_NAME/htdocs ]; then
mkdir -p /var/www/$FEDWIKI_DOMAIN_NAME/htdocs mkdir -p /var/www/$FEDWIKI_DOMAIN_NAME/htdocs
fi fi
if [ -d $FEDWIKI_DIR ]; then
rm -rf $FEDWIKI_DIR
fi
if [ ! -d $FEDWIKI_DATA ]; then if [ ! -d $FEDWIKI_DATA ]; then
mkdir -p $FEDWIKI_DATA mkdir -p $FEDWIKI_DATA
fi fi
groupadd fedwiki groupadd fedwiki
useradd -c "Fedwiki system account" -d $FEDWIKI_DIR -m -r -g fedwiki fedwiki useradd -c "Fedwiki system account" -d $FEDWIKI_DATA -m -r -g fedwiki fedwiki
if [ -d $FEDWIKI_DATA/Maildir ]; then
rm -rf $FEDWIKI_DATA/Maildir
fi
function_check install_nodejs function_check install_nodejs
install_nodejs fedwiki install_nodejs fedwiki
if [ -d /repos/fedwiki ]; then npm install -g wiki@$FEDWIKI_VERSION
mkdir -p $FEDWIKI_DIR
cp -r -p /repos/fedwiki/. $FEDWIKI_DIR
cd $FEDWIKI_DIR
git pull
else
function_check git_clone
git_clone $FEDWIKI_REPO $FEDWIKI_DIR
fi
cd $FEDWIKI_DIR
git checkout $FEDWIKI_COMMIT -b $FEDWIKI_COMMIT
set_completion_param "fedwiki commit" "$FEDWIKI_COMMIT"
npm install
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo $'Failed to install fedwiki' echo $'Failed to install fedwiki'
exit 8736254 exit 6293523
fi
if [ ! -f /usr/local/bin/wiki ]; then
echo $'wiki was not installed'
exit 5293524
fi fi
FEDWIKI_ONION_HOSTNAME=$(add_onion_service fedwiki 80 ${FEDWIKI_ONION_PORT}) FEDWIKI_ONION_HOSTNAME=$(add_onion_service fedwiki 80 ${FEDWIKI_ONION_PORT})
@ -375,8 +356,8 @@ function install_fedwiki {
echo '[Service]' >> /etc/systemd/system/fedwiki.service echo '[Service]' >> /etc/systemd/system/fedwiki.service
echo 'User=fedwiki' >> /etc/systemd/system/fedwiki.service echo 'User=fedwiki' >> /etc/systemd/system/fedwiki.service
echo 'Group=fedwiki' >> /etc/systemd/system/fedwiki.service echo 'Group=fedwiki' >> /etc/systemd/system/fedwiki.service
echo "WorkingDirectory=$FEDWIKI_DIR" >> /etc/systemd/system/fedwiki.service echo "WorkingDirectory=$FEDWIKI_DATA" >> /etc/systemd/system/fedwiki.service
echo "ExecStart=$FEDWIKI_DIR/wiki --data $FEDWIKI_DATA -p $FEDWIKI_PORT" >> /etc/systemd/system/fedwiki.service echo "ExecStart=/usr/local/bin/wiki --data $FEDWIKI_DATA -p $FEDWIKI_PORT" >> /etc/systemd/system/fedwiki.service
echo 'StandardOutput=syslog' >> /etc/systemd/system/fedwiki.service echo 'StandardOutput=syslog' >> /etc/systemd/system/fedwiki.service
echo 'StandardError=syslog' >> /etc/systemd/system/fedwiki.service echo 'StandardError=syslog' >> /etc/systemd/system/fedwiki.service
echo 'SyslogIdentifier=fedwiki' >> /etc/systemd/system/fedwiki.service echo 'SyslogIdentifier=fedwiki' >> /etc/systemd/system/fedwiki.service
@ -386,7 +367,6 @@ function install_fedwiki {
echo '[Install]' >> /etc/systemd/system/fedwiki.service echo '[Install]' >> /etc/systemd/system/fedwiki.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/fedwiki.service echo 'WantedBy=multi-user.target' >> /etc/systemd/system/fedwiki.service
chown -R fedwiki:fedwiki $FEDWIKI_DIR
chown -R fedwiki:fedwiki $FEDWIKI_DATA chown -R fedwiki:fedwiki $FEDWIKI_DATA
fedwiki_setup_web fedwiki_setup_web
@ -402,6 +382,7 @@ function install_fedwiki {
systemctl restart nginx systemctl restart nginx
set_completion_param "fedwiki domain" "$FEDWIKI_DOMAIN_NAME" set_completion_param "fedwiki domain" "$FEDWIKI_DOMAIN_NAME"
set_completion_param "fedwiki version" "$FEDWIKI_VERSION"
APP_INSTALLED=1 APP_INSTALLED=1
} }

View File

@ -1667,7 +1667,6 @@ function image_preinstall_repos {
git clone $KANBOARD_REPO $rootdir/repos/kanboard git clone $KANBOARD_REPO $rootdir/repos/kanboard
git clone $KEYSERVER_WEB_REPO $rootdir/repos/keyserverweb git clone $KEYSERVER_WEB_REPO $rootdir/repos/keyserverweb
git clone $PEERTUBE_REPO $rootdir/repos/peertube git clone $PEERTUBE_REPO $rootdir/repos/peertube
git clone $FEDWIKI_REPO $rootdir/repos/fedwiki
#git clone $WEKAN_REPO $rootdir/repos/wekan #git clone $WEKAN_REPO $rootdir/repos/wekan
#git clone $FLOW_ROUTER_REPO $rootdir/repos/flowrouter #git clone $FLOW_ROUTER_REPO $rootdir/repos/flowrouter
#git clone $METEOR_USERACCOUNTS_REPO $rootdir/repos/meteoruseraccounts #git clone $METEOR_USERACCOUNTS_REPO $rootdir/repos/meteoruseraccounts