snac.8 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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 operate a Linux systemd-enabled system or OpenBSD, there are
  67. startup scripts and configuration data in the
  68. .Pa examples
  69. directory.
  70. For other operating systems, please read the appropriate documentation
  71. on how to install a daemon as a non-root service.
  72. .Ss Server Setup
  73. .Pp
  74. An http server with TLS and proxying support must already be
  75. installed and configured.
  76. .Nm
  77. runs as a daemon and listens on a TCP/IP socket, preferrably
  78. on a local interface. It can serve the full domain or only
  79. a directory. The http server must be configured to route to the
  80. .Nm
  81. socket all related traffic and also the webfinger standard
  82. address. The Host header must be propagated.
  83. See the examples below.
  84. .Ss Adding Users
  85. .Pp
  86. Users must be created from the command line.
  87. You can do it by running
  88. .Bd -literal -offset indent
  89. snac adduser $HOME/snac-data
  90. .Ed
  91. .Pp
  92. All needed data will be prompted for. There is no artificial limit
  93. on the number of users that can be created.
  94. .Ss Customization
  95. The
  96. .Pa server.json
  97. configuration file allows some behaviour tuning:
  98. .Bl -tag -width tenletters
  99. .It Ic host
  100. The host name.
  101. .It Ic prefix
  102. The URL path prefix.
  103. .It Ic address
  104. The listen network address.
  105. .It Ic port
  106. The list network port.
  107. .It Ic dbglevel
  108. The debug level. An integer value, being 0 the less verbose (the default).
  109. .It Ic layout
  110. The disk storage layout version. Never touch this.
  111. .It Ic queue_retry_max
  112. Messages sent out are stored in a queue. If the posting of a messages fails,
  113. it's re-enqueued for later. This integer configures the maximum count of
  114. times the sending will be retried.
  115. .It Ic queue_retry_minutes
  116. The number of minutes to wait before the failed posting of a message is
  117. retried. This is not linear, but multipled by the number of retries
  118. already done.
  119. .It Ic max_timeline_entries
  120. This is the maximum timeline entries shown in the web interface.
  121. .It Ic timeline_purge_days
  122. Entries in the timeline older that this number of days are purged.
  123. .It Ic css_urls
  124. This is a list of URLs to CSS files that will be inserted, in this order,
  125. in the HTML before the user CSS. Use these files to configure the global
  126. site layout.
  127. .It Ic disable_cache
  128. If set to true, timeline caching is not done.
  129. .El
  130. .Pp
  131. You must restart the server to make effective these changes.
  132. .Pp
  133. If a file named
  134. .Pa greeting.html
  135. is present in the server base directory, it will be returned whenever
  136. the base URL of the server is requested. Fill it with whatever
  137. information about the instance you want to supply to people
  138. visiting the server, like sign up requirements, site policies
  139. and such. The special %userlist% mark in the file will cause
  140. the list of users in this instance to be inserted.
  141. .Pp
  142. Users can change a bit of information about themselves from the
  143. web interface. See
  144. .Xr snac 1
  145. for details. Further, every user has a private CSS file in their
  146. .Pa static/style.css
  147. that can be modified to suit their needs. This file contains
  148. a copy of the
  149. .Pa style.css
  150. file in the server root and it's inserted into the HTML output.
  151. It's not easily accesible from the web interface to avoid users
  152. shooting themselves in the foot by destroying everything.
  153. .Ss Old Data Purging
  154. The Fediverse generates big loads of data that get old and
  155. stale very quickly. By default,
  156. .Nm
  157. does not delete anything; you must do it explicitly by issuing a
  158. .Ar purge
  159. command periodically. A cron entry will suffice. You can add the
  160. following to the
  161. .Nm
  162. user's crontab:
  163. .Bd -literal -offset indent
  164. # execute a data purge on Sundays at 4 am
  165. 0 4 * * 0 /usr/local/bin/snac purge /path/to/snac-data
  166. .Ed
  167. .Pp
  168. The user-generated data (the local timeline) is never deleted.
  169. .Ss ActivityPub Support
  170. These are the following activities and objects that
  171. .Nm
  172. supports:
  173. .Bl -tag -width tenletters
  174. .It Vt Follow
  175. Complete support, on input and output.
  176. .It Vt Undo
  177. For
  178. .Vt Follow ,
  179. .Vt Like
  180. and
  181. .Vt Announce
  182. objects, on input and output.
  183. .It Vt Create
  184. For
  185. .Vt Note
  186. objects, on input and output.
  187. .It Vt Accept
  188. For
  189. .Vt Follow
  190. objects, on input and output.
  191. .It Vt Like
  192. For
  193. .Vt Note
  194. objects, on input and output.
  195. .It Vt Announce
  196. For
  197. .Vt Note
  198. objects, on input and output.
  199. .It Vt Update
  200. For
  201. .Vt Person
  202. objects, on input and output. Support for updating
  203. .Vt Note
  204. objects will probably be added in the future.
  205. .It Vt Delete
  206. Supported for
  207. .Vt Note
  208. and
  209. .Vt Tomsbtone
  210. objects on input, and for
  211. .Vt Note
  212. objects on output.
  213. .El
  214. .Pp
  215. The rest of activities and objects are dropped on input.
  216. .Pp
  217. There is partial support for
  218. .Vt OrderedCollection
  219. objects in the
  220. .Pa /outbox
  221. (with the last 20 entries of the local timeline shown). No pagination
  222. is supported. Intentionally, the
  223. .Pa /followers
  224. and
  225. .Pa /following
  226. paths return empty lists.
  227. .Ss Other Considerations
  228. .Nm
  229. stores all the messages it receives as JSON files, which are usually
  230. bloated and filled with redundant information. Using a filesystem with
  231. file compression enabled (like btrfs or zfs) will probably be a good
  232. choice to store the
  233. .Nm
  234. database into.
  235. .Sh ENVIRONMENT
  236. .Bl -tag -width Ds
  237. .It Ev DEBUG
  238. Overrides the debugging level from the server 'dbglevel' configuration
  239. variable. Set it to an integer value. The higher, the deeper in meaningless
  240. verbiage you'll find yourself into.
  241. .El
  242. .Sh EXAMPLES
  243. You want to install the
  244. .Nm
  245. Fediverse daemon in the host example.com, that is correctly configured
  246. with a valid TLS certificate and running the nginx httpd server.
  247. The service will be installed under the
  248. .Pa fedi
  249. location. Two users, walter and jessie, will be hosted in the system.
  250. Their Fediverse presence addresses will be https://example.com/fedi/walter
  251. and https://example.com/fedi/jesse, respectively. They will be known
  252. in the Fediverse as @walter@example.com and @jesse@example.com. The
  253. .Nm
  254. daemon will run as the user snacusr in the system and listen to the
  255. localhost:8001 network socket. All data will be stored in the
  256. .Pa /home/snacusr/fedidata
  257. directory.
  258. .Pp
  259. Log into the system as snacusr and execute:
  260. .Bd -literal -offset indent
  261. snac init /home/snacusr/fedidata
  262. .Ed
  263. .Pp
  264. Answer "example.com" to the host name question, "/fedi" to the path
  265. prefix question, "localhost" to the address and "8001" to the port.
  266. .Pp
  267. Create the users
  268. .Bd -literal -offset indent
  269. snac adduser /home/snacusr/fedidata walter
  270. snac adduser /home/snacusr/fedidata jesse
  271. .Ed
  272. .Pp
  273. Answer the questions with reasonable values.
  274. .Pp
  275. Execute the server:
  276. .Bd -literal -offset indent
  277. snac httpd /home/snacusr/fedidata
  278. .Ed
  279. .Pp
  280. Edit the nginx configuration and add the following snippet to the
  281. example.com server section:
  282. .Bd -literal -offset indent
  283. location /.well-known/webfinger {
  284. proxy_pass http://localhost:8001;
  285. proxy_set_header Host $http_host;
  286. }
  287. location /fedi {
  288. proxy_pass http://localhost:8001;
  289. proxy_set_header Host $http_host;
  290. }
  291. .Ed
  292. .Pp
  293. Restart the nginx daemon and connect to https://example.com/fedi/walter.
  294. The empty, default screen will be shown. Enter the admin section with the
  295. credentials defined for this user. Search people, start following
  296. them, engage in arid discussions and generally enjoy the frustrating
  297. experience of Social Media.
  298. .Sh SEE ALSO
  299. .Xr snac 1 ,
  300. .Xr snac 5
  301. .Sh AUTHORS
  302. .An grunfink
  303. .Sh LICENSE
  304. See the LICENSE file for details.
  305. .Sh CAVEATS
  306. JSON files are fragile when modified by hand. Take care.