snac.8 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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 Upgrading to a new version
  73. Sometimes, the database disk layout changes between versions. If there
  74. is such a change,
  75. .Nm
  76. will refuse to run and require an upgrade. Do this by running
  77. .Bd -literal -offset indent
  78. snac upgrade $HOME/snac-data
  79. .Ed
  80. Take special care to execute this upgrade operation without any
  81. .Nm
  82. processes serving on the same folder. You can break everything. I know
  83. this because Tyler knows this.
  84. .Pp
  85. .Ss Server Setup
  86. .Pp
  87. An http server with TLS and proxying support must already be
  88. installed and configured.
  89. .Nm
  90. runs as a daemon and listens on a TCP/IP socket, preferrably
  91. on a local interface. It can serve the full domain or only
  92. a directory. The http server must be configured to route to the
  93. .Nm
  94. socket all related traffic and also the webfinger standard
  95. address. The Host header must be propagated.
  96. See the examples below.
  97. .Ss Adding Users
  98. .Pp
  99. Users must be created from the command line.
  100. You can do it by running
  101. .Bd -literal -offset indent
  102. snac adduser $HOME/snac-data
  103. .Ed
  104. .Pp
  105. All needed data will be prompted for. There is no artificial limit
  106. on the number of users that can be created.
  107. .Ss Customization
  108. The
  109. .Pa server.json
  110. configuration file allows some behaviour tuning:
  111. .Bl -tag -width tenletters
  112. .It Ic host
  113. The host name.
  114. .It Ic prefix
  115. The URL path prefix.
  116. .It Ic address
  117. The listen network address.
  118. .It Ic port
  119. The list network port.
  120. .It Ic dbglevel
  121. The debug level. An integer value, being 0 the less verbose (the default).
  122. .It Ic layout
  123. The disk storage layout version. Never touch this.
  124. .It Ic queue_retry_max
  125. Messages sent out are stored in a queue. If the posting of a messages fails,
  126. it's re-enqueued for later. This integer configures the maximum count of
  127. times the sending will be retried.
  128. .It Ic queue_retry_minutes
  129. The number of minutes to wait before the failed posting of a message is
  130. retried. This is not linear, but multipled by the number of retries
  131. already done.
  132. .It Ic max_timeline_entries
  133. This is the maximum timeline entries shown in the web interface.
  134. .It Ic timeline_purge_days
  135. Entries in the timeline older that this number of days are purged.
  136. If you don't want any timeline purging and enjoy your data drives
  137. fill up with old crap and finally burst in flames, you can disable
  138. purging by setting this to 0.
  139. .It Ic local_purge_days
  140. Same as before, but for the user-generated entries in the local timeline.
  141. .It Ic css_urls
  142. This is a list of URLs to CSS files that will be inserted, in this order,
  143. in the HTML before the user CSS. Use these files to configure the global
  144. site layout.
  145. .It Ic disable_cache
  146. If set to true, timeline caching is not done. This is only useful for
  147. debugging purposes; don't enable it unless you know what do you want, as
  148. it makes everything slower.
  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. From version 2.06, there is no longer a need to add a special
  175. cron job for purging old data, as this is managed internally.
  176. .Ss ActivityPub Support
  177. These are the following activities and objects that
  178. .Nm
  179. supports:
  180. .Bl -tag -width tenletters
  181. .It Vt Follow
  182. Complete support, on input and output.
  183. .It Vt Undo
  184. For
  185. .Vt Follow ,
  186. .Vt Like
  187. and
  188. .Vt Announce
  189. objects, on input and output.
  190. .It Vt Create
  191. For
  192. .Vt Note
  193. objects, on input and output.
  194. .It Vt Accept
  195. For
  196. .Vt Follow
  197. objects, on input and output.
  198. .It Vt Like
  199. For
  200. .Vt Note
  201. objects, on input and output.
  202. .It Vt Announce
  203. For
  204. .Vt Note
  205. objects, on input and output.
  206. .It Vt Update
  207. For
  208. .Vt Person
  209. objects, on input and output. Support for updating
  210. .Vt Note
  211. objects will probably be added in the future.
  212. .It Vt Delete
  213. Supported for
  214. .Vt Note
  215. and
  216. .Vt Tomsbtone
  217. objects on input, and for
  218. .Vt Note
  219. objects on output.
  220. .El
  221. .Pp
  222. The rest of activities and objects are dropped on input.
  223. .Pp
  224. There is partial support for
  225. .Vt OrderedCollection
  226. objects in the
  227. .Pa /outbox
  228. (with the last 20 entries of the local timeline shown). No pagination
  229. is supported. Intentionally, the
  230. .Pa /followers
  231. and
  232. .Pa /following
  233. paths return empty lists.
  234. .Ss Migrating from Mastodon
  235. User migration from different Fediverse instances is a pain in the ass
  236. that has been implemented everywhere as a kludgy afterthought. There is
  237. not much that can be done, other than importing the list of people you
  238. follow to your new
  239. .Nm
  240. account.
  241. .Pp
  242. To do this, download the user's list of accounts being followed (in CSV
  243. format) from the Mastodon web interface and execute this:
  244. .Bd -literal -offset indent
  245. awk -F, 'NR > 1 { print $1 }' /path/to/following_accounts.csv | \\
  246. xargs -n 1 snac follow $SNAC_BASEDIR $SNAC_USER
  247. .Ed
  248. .Ss Other Considerations
  249. .Nm
  250. stores all the messages it receives as JSON files, which are usually
  251. bloated and filled with redundant information. Using a filesystem with
  252. file compression enabled (like btrfs or zfs) will probably be a good
  253. choice to store the
  254. .Nm
  255. database into.
  256. .Sh ENVIRONMENT
  257. .Bl -tag -width Ds
  258. .It Ev DEBUG
  259. Overrides the debugging level from the server 'dbglevel' configuration
  260. variable. Set it to an integer value. The higher, the deeper in meaningless
  261. verbiage you'll find yourself into.
  262. .El
  263. .Sh EXAMPLES
  264. You want to install the
  265. .Nm
  266. Fediverse daemon in the host example.com, that is correctly configured
  267. with a valid TLS certificate and running the nginx httpd server.
  268. The service will be installed under the
  269. .Pa fedi
  270. location. Two users, walter and jessie, will be hosted in the system.
  271. Their Fediverse presence addresses will be https://example.com/fedi/walter
  272. and https://example.com/fedi/jesse, respectively. They will be known
  273. in the Fediverse as @walter@example.com and @jesse@example.com. The
  274. .Nm
  275. daemon will run as the user snacusr in the system and listen to the
  276. localhost:8001 network socket. All data will be stored in the
  277. .Pa /home/snacusr/fedidata
  278. directory.
  279. .Pp
  280. Log into the system as snacusr and execute:
  281. .Bd -literal -offset indent
  282. snac init /home/snacusr/fedidata
  283. .Ed
  284. .Pp
  285. Answer "example.com" to the host name question, "/fedi" to the path
  286. prefix question, "localhost" to the address and "8001" to the port.
  287. .Pp
  288. Create the users
  289. .Bd -literal -offset indent
  290. snac adduser /home/snacusr/fedidata walter
  291. snac adduser /home/snacusr/fedidata jesse
  292. .Ed
  293. .Pp
  294. Answer the questions with reasonable values.
  295. .Pp
  296. Execute the server:
  297. .Bd -literal -offset indent
  298. snac httpd /home/snacusr/fedidata
  299. .Ed
  300. .Pp
  301. Edit the nginx configuration and add the following snippet to the
  302. example.com server section:
  303. .Bd -literal -offset indent
  304. location /.well-known/webfinger {
  305. proxy_pass http://localhost:8001;
  306. proxy_set_header Host $http_host;
  307. }
  308. location /fedi {
  309. proxy_pass http://localhost:8001;
  310. proxy_set_header Host $http_host;
  311. }
  312. .Ed
  313. .Pp
  314. Restart the nginx daemon and connect to https://example.com/fedi/walter.
  315. The empty, default screen will be shown. Enter the admin section with the
  316. credentials defined for this user. Search people, start following
  317. them, engage in arid discussions and generally enjoy the frustrating
  318. experience of Social Media.
  319. .Sh SEE ALSO
  320. .Xr snac 1 ,
  321. .Xr snac 5
  322. .Sh AUTHORS
  323. .An grunfink @grunfink@comam.es
  324. .Sh LICENSE
  325. See the LICENSE file for details.
  326. .Sh CAVEATS
  327. JSON files are fragile when modified by hand. Take care.