1. create a directory for tiddlywiki
mkdir tdwiki
2. Under this directory, initialize a notebook named "mywiki"
user:~/tdwiki$ tiddlywiki mywiki --init server
Copied edition 'server' to mywiki
After this command, we are supposed to a see sub-directory named "mywiki" created under the parent directory "tdwiki"
3. To load exting tiddlers in index_2015-9-23.html created by tiddlywiki desktop verion
3.1 --type the help on load command
user:~/tdwiki$ tiddlywiki --help load
Load tiddlers from 2.x.x TiddlyWiki files (.html), .tiddler, .tid, .json or other files
3.2 --actual loading
To load tiddlers from the exsiting html file.
tiddlywiki ./MyWiki --load my_encrypted_wiki.html
user:~/tdwiki$ tiddlywiki ./mywiki --load index_2015-9-23.html
syncer-server: Dispatching 'save' task: $:/StoryList
FileSystem: Saved file /home/user/tdwiki/mywiki/tiddlers/$__StoryList.tid
syncer-server: Dispatching 'save' task: bf Operator
FileSystem: Saved file /home/user/tdwiki/mywiki/tiddlers/bf_Operator.tid
syncer-server: Dispatching 'save' task: BetaReleases
FileSystem: Saved file /home/user/tdwiki/mywiki/tiddlers/BetaReleases.tid
syncer-server: Dispatching 'save' task: before Operator (Examples)
FileSystem: Saved file /home/user/tdwiki/mywiki/tiddlers/before_Operator_(Examples).tid
syncer-server: Dispatching 'save' task: before Operator
FileSystem: Saved file /home/user/tdwiki/mywiki/tiddlers/before_Operator.tid
...
4. verify that many tiddlers are created under the "miwiki" subdirectory
5. finaly, start the tiddlywiki service for "mywiki" on port 8080 of server ip 192.168.0.96, with logon id & password
nohup /usr/local/bin/tiddlywiki /home/user/tdwiki/mywiki --server 8080 $:/core/save/all text/plain text/html user xxxxxxx 192.168.0.96 &
6. To permanent add it as sysv service in 14.04. I created the following 3 scripts for init.d service to start the service called "mywiki" automatically upon rebooting.
/home/user/tdwiki/start_mywiki.sh
/home/user/tdwiki/stop_mywiki.sh
/etc/init.d/mywiki
user:~/tdwiki$ cat start_mywiki.sh
#!/bin/bash
nohup /usr/local/bin/tiddlywiki /home/user/tdwiki/mywiki --server 8080 $:/core/save/all text/plain text/html user xxxxxxx 192.168.0.96 &
user:~/tdwiki$ cat stop_mywiki.sh
#!/bin/bash
ps -fu user |grep mywiki |grep 8080 |awk '{ print $2 }' | xargs kill
#Note here the scipt name /etc/init.d/mywiki should not have the suffix ".sh"
user:~/tdwiki$ cat /etc/init.d/mywiki
#! /bin/sh
### BEGIN INIT INFO
# Provides: daoqidao wiki
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: for daoqidao tiddlywiki service
# Description: This file starts and stops tiddlywiki server
#
### END INIT INFO
case "$1" in
start)
su user -c /home/user/tdwiki/start_mywiki.sh
;;
stop)
su user -c /home/user/tdwiki/stop_mywiki.sh
sleep 1
;;
status)
ps -fu user |grep mywiki |grep 8080
;;
restart)
su user -c /home/user/tdwiki/stop_mywiki.sh
sleep 2
su user -c /home/user/tdwiki/start_mywiki.sh
;;
*)
echo "Usage: mywiki {start|stop|restart}" >&2
exit 3
;;
esac
7. If all goes well then register the script as an init script:
sudo update-rc.d mywiki defaults
8. Reboot the machine and make sure that Tomcat has started.
References: https://mobiarch.wordpress.com/2014/05/16/creating-an-init-script-in-ubuntu-14-04/
9. I also created a such service in one Ubuntu 15.04, which uses systemd instead to manage the service. The script is different.
user:~/tdwiki/ubuntu15.04$ cat /etc/tiddlywiki.conf
WIKI=/home/user/tdwiki/mywiki
PORT=8080
OPTS="$:/core/save/all text/plain text/html"
USER=user
PWD=xxxxxxx
IP=192.168.0.96
user:~/tdwiki/ubuntu15.04$ cat tiddlywiki.service
[Unit]
Description=TiddlyWiki
After=syslog.target
[Service]
User=user
Group=user
SyslogIdentifier=tiddlywiki
Restart=always
setuid=1000
StandardOutput=syslog
EnvironmentFile=/etc/tiddlywiki.conf
ExecStart=/usr/local/bin/tiddlywiki $WIKI --server $PORT $OPTS $USER $PWD $IP
[Install]
WantedBy=multi-user.target
10. move the file tiddlywiki.service to /etc/systemd/system and ran sudo systemctl enable tiddlywiki.service to create link scripts.
11. Restart server for verification
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment