snac.8 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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 Special cares about your snac you must know beforehand
  18. .Nm
  19. makes heavy use of hard links and link reference counts for its work, so
  20. don't even think of using it on a filesystem that doesn't support this
  21. feature. Most UNIX-like operating systems (Linux, the BSDs, the old DEC
  22. Ultrix machine in your grandfather basement, probably MacOS) support hard
  23. links on their native filesystems. Don't do fancy things like moving the
  24. subdirectories to different filesystems. Also, if you move your
  25. .Nm
  26. installation to another server, do it with a tool that respect hard
  27. link counts. Remember:
  28. .Nm
  29. is a very UNIXy program that loves hard links.
  30. .Ss Building and Installation
  31. A C compiler must be installed in the system, as well as the development
  32. headers and libraries for OpenSSL and curl. To build
  33. .Nm ,
  34. run
  35. .Bd -literal -offset indent
  36. make
  37. .Ed
  38. .Pp
  39. And, after that, run as root
  40. .Bd -literal -offset indent
  41. make install
  42. .Ed
  43. .Ss Database Initialization
  44. Once
  45. .Nm
  46. is properly installed on the system, designate a directory where
  47. the server and user data are to be stored. This directory
  48. must not exist yet.
  49. .Nm
  50. must always be run as a regular user; you can create one for
  51. it or use your own. To initialize the database, execute
  52. .Bd -literal -offset indent
  53. snac init $HOME/snac-data
  54. .Ed
  55. .Pp
  56. A small set of questions will be asked regarding the installation,
  57. specially the host name it will run under, the local network address
  58. and port
  59. .Nm
  60. will listen to, the optional path prefix and possibly other things.
  61. .Pp
  62. You can launch the
  63. .Nm
  64. process by running
  65. .Bd -literal -offset indent
  66. snac httpd $HOME/snac-data
  67. .Ed
  68. .Pp
  69. Use a web browser to connect to the specified address and port. You
  70. should see a greeting page.
  71. .Pp
  72. Log messages are sent to the standard error stream. By default, only
  73. relevant information is written there. You can increase the debugging
  74. level by editing the 'dbglevel' field in the
  75. .Pa server.json
  76. file or by setting a numeric value between 0 and 3 to the DEBUG
  77. environment variable, see below.
  78. .Pp
  79. If you operate a Linux systemd-enabled system or OpenBSD, there are
  80. startup scripts and configuration data in the
  81. .Pa examples
  82. directory.
  83. For other operating systems, please read the appropriate documentation
  84. on how to install a daemon as a non-root service.
  85. .Ss Upgrading to a new version
  86. Sometimes, the database disk layout changes between versions. If there
  87. is such a change,
  88. .Nm
  89. will refuse to run and require an upgrade. Do this by running
  90. .Bd -literal -offset indent
  91. snac upgrade $HOME/snac-data
  92. .Ed
  93. Take special care to execute this upgrade operation without any
  94. .Nm
  95. processes serving on the same folder. You can break everything. I know
  96. this because Tyler knows this.
  97. .Pp
  98. .Ss Server Setup
  99. .Pp
  100. An http server with TLS and proxying support must already be
  101. installed and configured.
  102. .Nm
  103. runs as a daemon and listens on a TCP/IP socket, preferrably
  104. on a local interface. It can serve the full domain or only
  105. a directory. The http server must be configured to route to the
  106. .Nm
  107. socket all related traffic and also the webfinger standard
  108. address. The Host header must be propagated.
  109. See the examples below.
  110. .Ss Adding Users
  111. .Pp
  112. Users must be created from the command line.
  113. You can do it by running
  114. .Bd -literal -offset indent
  115. snac adduser $HOME/snac-data
  116. .Ed
  117. .Pp
  118. All needed data will be prompted for. There is no artificial limit
  119. on the number of users that can be created.
  120. .Ss Customization
  121. The
  122. .Pa server.json
  123. configuration file allows some behaviour tuning:
  124. .Bl -tag -width tenletters
  125. .It Ic host
  126. The host name.
  127. .It Ic prefix
  128. The URL path prefix.
  129. .It Ic address
  130. The listen network address.
  131. .It Ic port
  132. The list network port.
  133. .It Ic dbglevel
  134. The debug level. An integer value, being 0 the less verbose (the default).
  135. .It Ic layout
  136. The disk storage layout version. Never touch this.
  137. .It Ic queue_retry_max
  138. Messages sent out are stored in a queue. If the posting of a messages fails,
  139. it's re-enqueued for later. This integer configures the maximum count of
  140. times the sending will be retried.
  141. .It Ic queue_retry_minutes
  142. The number of minutes to wait before the failed posting of a message is
  143. retried. This is not linear, but multipled by the number of retries
  144. already done.
  145. .It Ic max_timeline_entries
  146. This is the maximum timeline entries shown in the web interface.
  147. .It Ic timeline_purge_days
  148. Entries in the timeline older that this number of days are purged.
  149. If you don't want any timeline purging and enjoy your data drives
  150. fill up with old crap and finally burst in flames, you can disable
  151. purging by setting this to 0.
  152. .It Ic local_purge_days
  153. Same as before, but for the user-generated entries in the local timeline.
  154. .It Ic css_urls
  155. This is a list of URLs to CSS files that will be inserted, in this order,
  156. in the HTML before the user CSS. Use these files to configure the global
  157. site layout.
  158. .It Ic disable_cache
  159. If set to true, timeline caching is not done. This is only useful for
  160. debugging purposes; don't enable it unless you know what do you want, as
  161. it makes everything slower.
  162. .El
  163. .Pp
  164. You must restart the server to make effective these changes.
  165. .Pp
  166. If a file named
  167. .Pa greeting.html
  168. is present in the server base directory, it will be returned whenever
  169. the base URL of the server is requested. Fill it with whatever
  170. information about the instance you want to supply to people
  171. visiting the server, like sign up requirements, site policies
  172. and such. The special %userlist% mark in the file will cause
  173. the list of users in this instance to be inserted.
  174. .Pp
  175. Users can change a bit of information about themselves from the
  176. web interface. See
  177. .Xr snac 1
  178. for details. Further, every user has a private CSS file in their
  179. .Pa static/style.css
  180. that can be modified to suit their needs. This file contains
  181. a copy of the
  182. .Pa style.css
  183. file in the server root and it's inserted into the HTML output.
  184. It's not easily accesible from the web interface to avoid users
  185. shooting themselves in the foot by destroying everything.
  186. .Ss Old Data Purging
  187. From version 2.06, there is no longer a need to add a special
  188. cron job for purging old data, as this is managed internally.
  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 Migrating from Mastodon
  248. User migration from different Fediverse instances is a pain in the ass
  249. that has been implemented everywhere as a kludgy afterthought. There is
  250. not much that can be done, other than importing the list of people you
  251. follow to your new
  252. .Nm
  253. account.
  254. .Pp
  255. To do this, download the user's list of accounts being followed (in CSV
  256. format) from the Mastodon web interface and execute this:
  257. .Bd -literal -offset indent
  258. awk -F, 'NR > 1 { print $1 }' /path/to/following_accounts.csv | \\
  259. xargs -n 1 snac follow $SNAC_BASEDIR $SNAC_USER
  260. .Ed
  261. .Ss Other Considerations
  262. .Nm
  263. stores all the messages it receives as JSON files, which are usually
  264. bloated and filled with redundant information. Using a filesystem with
  265. file compression enabled (like btrfs or zfs) will probably be a good
  266. choice to store the
  267. .Nm
  268. database into.
  269. .Sh ENVIRONMENT
  270. .Bl -tag -width Ds
  271. .It Ev DEBUG
  272. Overrides the debugging level from the server 'dbglevel' configuration
  273. variable. Set it to an integer value. The higher, the deeper in meaningless
  274. verbiage you'll find yourself into.
  275. .El
  276. .Sh EXAMPLES
  277. You want to install the
  278. .Nm
  279. Fediverse daemon in the host example.com, that is correctly configured
  280. with a valid TLS certificate and running the nginx httpd server.
  281. The service will be installed under the
  282. .Pa fedi
  283. location. Two users, walter and jessie, will be hosted in the system.
  284. Their Fediverse presence addresses will be https://example.com/fedi/walter
  285. and https://example.com/fedi/jesse, respectively. They will be known
  286. in the Fediverse as @walter@example.com and @jesse@example.com. The
  287. .Nm
  288. daemon will run as the user snacusr in the system and listen to the
  289. localhost:8001 network socket. All data will be stored in the
  290. .Pa /home/snacusr/fedidata
  291. directory.
  292. .Pp
  293. Log into the system as snacusr and execute:
  294. .Bd -literal -offset indent
  295. snac init /home/snacusr/fedidata
  296. .Ed
  297. .Pp
  298. Answer "example.com" to the host name question, "/fedi" to the path
  299. prefix question, "localhost" to the address and "8001" to the port.
  300. .Pp
  301. Create the users
  302. .Bd -literal -offset indent
  303. snac adduser /home/snacusr/fedidata walter
  304. snac adduser /home/snacusr/fedidata jesse
  305. .Ed
  306. .Pp
  307. Answer the questions with reasonable values.
  308. .Pp
  309. Execute the server:
  310. .Bd -literal -offset indent
  311. snac httpd /home/snacusr/fedidata
  312. .Ed
  313. .Pp
  314. Edit the nginx configuration and add the following snippet to the
  315. example.com server section:
  316. .Bd -literal -offset indent
  317. location /.well-known/webfinger {
  318. proxy_pass http://localhost:8001;
  319. proxy_set_header Host $http_host;
  320. }
  321. location /fedi {
  322. proxy_pass http://localhost:8001;
  323. proxy_set_header Host $http_host;
  324. }
  325. .Ed
  326. .Pp
  327. Restart the nginx daemon and connect to https://example.com/fedi/walter.
  328. The empty, default screen will be shown. Enter the admin section with the
  329. credentials defined for this user. Search people, start following
  330. them, engage in arid discussions and generally enjoy the frustrating
  331. experience of Social Media.
  332. .Sh SEE ALSO
  333. .Xr snac 1 ,
  334. .Xr snac 5
  335. .Sh AUTHORS
  336. .An grunfink @grunfink@comam.es
  337. .Sh LICENSE
  338. See the LICENSE file for details.
  339. .Sh CAVEATS
  340. JSON files are fragile when modified by hand. Take care.