snac.8 9.0 KB

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