snac.8 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. .Dd $Mdocdate$
  2. .Dt SNAC 8
  3. .Os
  4. .Sh NAME
  5. .Nm snac
  6. .Nd snac administration
  7. .Sh DESCRIPTION
  8. The
  9. .Nm
  10. daemon processes messages from other servers in the Fediverse
  11. using the ActivityPub protocol.
  12. .Pp
  13. This is the admin manual. For user operation, see
  14. .Xr snac 1 .
  15. For file and data formats, see
  16. .Xr snac 5 .
  17. .Ss Building and Installation
  18. A C compiler must be installed in the system, as well as the development
  19. headers and libraries for OpenSSL and curl. To build
  20. .Nm ,
  21. run
  22. .Bd -literal -offset indent
  23. make
  24. .Ed
  25. .Pp
  26. And, after that, run as root
  27. .Bd -literal -offset indent
  28. make install
  29. .Ed
  30. .Ss Database Initialization
  31. Once
  32. .Nm
  33. is properly installed on the system, designate a directory where
  34. the server and user data are to be stored. This directory
  35. must not exist yet.
  36. .Nm
  37. must always be run as a regular user; you can create one for
  38. it or use your own. To initialize the database, execute
  39. .Bd -literal -offset indent
  40. snac init $HOME/snac-data
  41. .Ed
  42. .Pp
  43. A small set of questions will be asked regarding the installation,
  44. specially the host name it will run under, the local network address
  45. and port
  46. .Nm
  47. will listen to, the optional path prefix and possibly other things.
  48. .Pp
  49. You can launch the
  50. .Nm
  51. process by running
  52. .Bd -literal -offset indent
  53. snac httpd $HOME/snac-data
  54. .Ed
  55. .Pp
  56. Use a web browser to connect to the specified address and port. You
  57. should see a greeting page.
  58. .Pp
  59. Log messages are sent to the standard error stream. By default, only
  60. relevant information is written there. You can increase the debugging
  61. level by editing the 'dbglevel' field in the
  62. .Pa server.json
  63. file or by setting a numeric value between 0 and 3 to the DEBUG
  64. environment variable, see below.
  65. .Pp
  66. If you run
  67. .Nm
  68. in an OS controlled by
  69. .Xr systemd 1 ,
  70. you can prepare a user service to start/stop the daemon. Following the
  71. previous example, create the file
  72. .Pa ~/.config/systemd/user/snac.service
  73. with the following content:
  74. .Bd -literal -offset indent
  75. [Unit]
  76. Description=snac daemon
  77. [Service]
  78. Type=simple
  79. Restart=always
  80. RestartSec=5
  81. ExecStart=/usr/local/bin/snac httpd /path/to/snac-data
  82. [Install]
  83. WantedBy=default.target
  84. .Ed
  85. .Pp
  86. And activate it by running
  87. .Bd -literal -offset indent
  88. systemctl --user enable snac.service
  89. systemctl --user start snac.service
  90. .Ed
  91. .Pp
  92. For other operating systems, please read the appropriate documentation
  93. on how to install a daemon as a non-root service.
  94. .Ss Server Setup
  95. .Pp
  96. An http server with TLS and proxying support must already be
  97. installed and configured.
  98. .Nm
  99. runs as a daemon and listens on a TCP/IP socket, preferrably
  100. on a local interface. It can serve the full domain or only
  101. a directory. The http server must be configured to route to the
  102. .Nm
  103. socket all related traffic and also the webfinger standard
  104. address. The Host header must be propagated.
  105. See the examples below.
  106. .Ss Adding Users
  107. .Pp
  108. Users must be created from the command line.
  109. You can do it by running
  110. .Bd -literal -offset indent
  111. snac adduser $HOME/snac-data
  112. .Ed
  113. .Pp
  114. All needed data will be prompted for. There is no artificial limit
  115. on the number of users that can be created.
  116. .Ss Customization
  117. The
  118. .Pa server.json
  119. configuration file allows some behaviour tuning:
  120. .Bl -tag -width tenletters
  121. .It Ic host
  122. The host name.
  123. .It Ic prefix
  124. The URL path prefix.
  125. .It Ic address
  126. The listen network address.
  127. .It Ic port
  128. The list network port.
  129. .It Ic dbglevel
  130. The debug level. An integer value, being 0 the less verbose (the default).
  131. .It Ic layout
  132. The disk storage layout version. Never touch this.
  133. .It Ic queue_retry_max
  134. Messages sent out are stored in a queue. If the posting of a messages fails,
  135. it's re-enqueued for later. This integer configures the maximum count of
  136. times the sending will be retried.
  137. .It Ic queue_retry_minutes
  138. The number of minutes to wait before the failed posting of a message is
  139. retried. This is not linear, but multipled by the number of retries
  140. already done.
  141. .It Ic max_timeline_entries
  142. This is the maximum timeline entries shown in the web interface.
  143. .It Ic timeline_purge_days
  144. Entries in the timeline older that this number of days are purged.
  145. .It Ic css_urls
  146. This is a list of URLs to CSS files that will be inserted, in this order,
  147. in the HTML before the user CSS. Use these files to configure the global
  148. site layout.
  149. .El
  150. .Pp
  151. You must restart the server to make effective these changes.
  152. .Pp
  153. If a file named
  154. .Pa greeting.html
  155. is present in the server base directory, it will be returned whenever
  156. the base URL of the server is requested. Fill it with whatever
  157. information about the instance you want to supply to people
  158. visiting the server, like sign up requirements, site policies
  159. and such. The special %userlist% mark in the file will cause
  160. the list of users in this instance to be inserted.
  161. .Pp
  162. Users can change a bit of information about themselves from the
  163. web interface. See
  164. .Xr snac 1
  165. for details. Further, every user has a private CSS file in their
  166. .Pa static/style.css
  167. that can be modified to suit their needs. This file contains
  168. a copy of the
  169. .Pa style.css
  170. file in the server root and it's inserted into the HTML output.
  171. It's not easily accesible from the web interface to avoid users
  172. shooting themselves in the foot by destroying everything.
  173. .Ss Old Data Purging
  174. The Fediverse generates big loads of data that get old and
  175. stale very quickly. By default,
  176. .Nm
  177. does not delete anything; you must do it explicitly by issuing a
  178. .Ar purge
  179. command periodically. A cron entry will suffice. You can add the
  180. following to the
  181. .Nm
  182. user's crontab:
  183. .Bd -literal -offset indent
  184. # execute a data purge on Sundays at 4 am
  185. 0 4 * * 0 /usr/local/bin/snac purge /path/to/snac-data
  186. .Ed
  187. .Pp
  188. The user-generated data (the local timeline) is never deleted.
  189. .Ss ActivityPub Support
  190. These are the following activities and objects that
  191. .Nm
  192. supports:
  193. .Bl -tag -width tenletters
  194. .It Vt Follow
  195. Complete support, on input and output.
  196. .It Vt Undo
  197. For
  198. .Vt Follow ,
  199. .Vt Like
  200. and
  201. .Vt Announce
  202. objects, on input and output.
  203. .It Vt Create
  204. For
  205. .Vt Note
  206. objects, on input and output.
  207. .It Vt Accept
  208. For
  209. .Vt Follow
  210. objects, on input and output.
  211. .It Vt Like
  212. For
  213. .Vt Note
  214. objects, on input and output.
  215. .It Vt Announce
  216. For
  217. .Vt Note
  218. objects, on input and output.
  219. .It Vt Update
  220. For
  221. .Vt Person
  222. objects, on input and output. Support for updating
  223. .Vt Note
  224. objects will probably be added in the future.
  225. .It Vt Delete
  226. Supported for
  227. .Vt Note
  228. and
  229. .Vt Tomsbtone
  230. objects on input, and for
  231. .Vt Note
  232. objects on output.
  233. .El
  234. .Pp
  235. The rest of activities and objects are dropped on input.
  236. .Pp
  237. There is partial support for
  238. .Vt OrderedCollection
  239. objects in the
  240. .Pa /outbox
  241. (with the last 20 entries of the local timeline shown). No pagination
  242. is supported. Intentionally, the
  243. .Pa /followers
  244. and
  245. .Pa /following
  246. paths return empty lists.
  247. .Ss Other Considerations
  248. .Nm
  249. stores all the messages it receives as JSON files, which are usually
  250. bloated and filled with redundant information. Using a filesystem with
  251. file compression enabled (like btrfs or zfs) will probably be a good
  252. choice to store the
  253. .Nm
  254. database into.
  255. .Sh ENVIRONMENT
  256. .Bl -tag -width Ds
  257. .It Ev DEBUG
  258. Overrides the debugging level from the server 'dbglevel' configuration
  259. variable. Set it to an integer value. The higher, the deeper in meaningless
  260. verbiage you'll find yourself into.
  261. .El
  262. .Sh EXAMPLES
  263. You want to install the
  264. .Nm
  265. Fediverse daemon in the host example.com, that is correctly configured
  266. with a valid TLS certificate and running the nginx httpd server.
  267. The service will be installed under the
  268. .Pa fedi
  269. location. Two users, walter and jessie, will be hosted in the system.
  270. Their Fediverse presence addresses will be https://example.com/fedi/walter
  271. and https://example.com/fedi/jesse, respectively. They will be known
  272. in the Fediverse as @walter@example.com and @jesse@example.com. The
  273. .Nm
  274. daemon will run as the user snacusr in the system and listen to the
  275. localhost:8001 network socket. All data will be stored in the
  276. .Pa /home/snacusr/fedidata
  277. directory.
  278. .Pp
  279. Log into the system as snacusr and execute:
  280. .Bd -literal -offset indent
  281. snac init /home/snacusr/fedidata
  282. .Ed
  283. .Pp
  284. Answer "example.com" to the host name question, "/fedi" to the path
  285. prefix question, "localhost" to the address and "8001" to the port.
  286. .Pp
  287. Create the users
  288. .Bd -literal -offset indent
  289. snac adduser /home/snacusr/fedidata walter
  290. snac adduser /home/snacusr/fedidata jesse
  291. .Ed
  292. .Pp
  293. Answer the questions with reasonable values.
  294. .Pp
  295. Execute the server:
  296. .Bd -literal -offset indent
  297. snac httpd /home/snacusr/fedidata
  298. .Ed
  299. .Pp
  300. Edit the nginx configuration and add the following snippet to the
  301. example.com server section:
  302. .Bd -literal -offset indent
  303. location /.well-known/webfinger {
  304. proxy_pass http://localhost:8001;
  305. proxy_set_header Host $http_host;
  306. }
  307. location /fedi {
  308. proxy_pass http://localhost:8001;
  309. proxy_set_header Host $http_host;
  310. }
  311. .Ed
  312. .Pp
  313. Restart the nginx daemon and connect to https://example.com/fedi/walter.
  314. The empty, default screen will be shown. Enter the admin section with the
  315. credentials defined for this user. Search people, start following
  316. them, engage in arid discussions and generally enjoy the frustrating
  317. experience of Social Media.
  318. .Sh SEE ALSO
  319. .Xr snac 1 ,
  320. .Xr snac 5
  321. .Sh AUTHORS
  322. .An grunfink
  323. .Sh LICENSE
  324. See the LICENSE file for details.
  325. .Sh CAVEATS
  326. JSON files are fragile when modified by hand. Take care.