snac.8 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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 (or compatible) 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 Data storage 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 data storage, 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 data storage 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. .Pp
  94. Take special care to execute this upgrade operation without any
  95. .Nm
  96. processes serving on the same folder. You can break everything. I know
  97. this because Tyler knows this.
  98. .Pp
  99. .Ss Server Setup
  100. .Pp
  101. An http server with TLS and proxying support must already be
  102. installed and configured.
  103. .Nm
  104. runs as a daemon and listens on a TCP/IP socket, preferrably
  105. on a local interface. It can serve the full domain or only
  106. a directory. The http server must be configured to route to the
  107. .Nm
  108. socket all related traffic and also the webfinger standard
  109. address. The Host header must be propagated.
  110. See the examples below.
  111. .Ss Adding Users
  112. .Pp
  113. Users must be created from the command line.
  114. You can do it by running
  115. .Bd -literal -offset indent
  116. snac adduser $HOME/snac-data
  117. .Ed
  118. .Pp
  119. All needed data will be prompted for. There is no artificial limit
  120. on the number of users that can be created.
  121. .Ss Customization
  122. The
  123. .Pa server.json
  124. configuration file allows some behaviour tuning:
  125. .Bl -tag -width tenletters
  126. .It Ic host
  127. The host name.
  128. .It Ic prefix
  129. The URL path prefix.
  130. .It Ic address
  131. The listen network address.
  132. .It Ic port
  133. The listen network port.
  134. .It Ic dbglevel
  135. The debug level. An integer value, being 0 the less verbose (the default).
  136. .It Ic layout
  137. The disk storage layout version. Never touch this.
  138. .It Ic queue_retry_max
  139. Messages sent out are stored in a queue. If the posting of a messages fails,
  140. it's re-enqueued for later. This integer configures the maximum count of
  141. times the sending will be retried.
  142. .It Ic queue_retry_minutes
  143. The number of minutes to wait before the failed posting of a message is
  144. retried. This is not linear, but multipled by the number of retries
  145. already done.
  146. .It Ic max_timeline_entries
  147. This is the maximum timeline entries shown in the web interface.
  148. .It Ic timeline_purge_days
  149. Entries in the timeline older that this number of days are purged.
  150. If you don't want any timeline purging and enjoy your data drives
  151. fill up with old crap and finally burst in flames, you can disable
  152. purging by setting this to 0.
  153. .It Ic local_purge_days
  154. Same as before, but for the user-generated entries in the local timeline.
  155. .It Ic cssurls
  156. This is a list of URLs to CSS files that will be inserted, in this order,
  157. in the HTML before the user CSS. Use these files to configure the global
  158. site layout.
  159. .It Ic disable_cache
  160. If set to true, timeline caching is not done. This is only useful for
  161. debugging purposes; don't enable it unless you know what do you want, as
  162. it makes everything slower.
  163. .It Ic disable_openbsd_security
  164. If running under OpenBSD,
  165. .Nm
  166. makes use of the enhanced security functions
  167. .Xr unveil 2
  168. and
  169. .Xr pledge 2 .
  170. Setting this to true disables their usage. These functions limit severely
  171. what an intruder can do in case of a security vulnerability, so only enable
  172. this option if something is very broken.
  173. .It Ic num_threads
  174. By setting this value, you can specify the exact number of threads
  175. .Nm
  176. will use when processing connections. Values lesser than 4 will be ignored.
  177. .El
  178. .Pp
  179. You must restart the server to make effective these changes.
  180. .Pp
  181. If a file named
  182. .Pa greeting.html
  183. is present in the server base directory, it will be returned whenever
  184. the base URL of the server is requested. Fill it with whatever
  185. information about the instance you want to supply to people
  186. visiting the server, like sign up requirements, site policies
  187. and such. The special %userlist% mark in the file will cause
  188. the list of users in this instance to be inserted.
  189. .Pp
  190. Users can change a bit of information about themselves from the
  191. web interface. See
  192. .Xr snac 1
  193. for details. Further, every user has a private CSS file in their
  194. .Pa static/style.css
  195. that can be modified to suit their needs. This file contains
  196. a copy of the
  197. .Pa style.css
  198. file in the server root and it's inserted into the HTML output.
  199. It's not easily accesible from the web interface to avoid users
  200. shooting themselves in the foot by destroying everything.
  201. .Ss Old Data Purging
  202. From version 2.06, there is no longer a need to add a special
  203. cron job for purging old data, as this is managed internally.
  204. .Ss ActivityPub Support
  205. These are the following activities and objects that
  206. .Nm
  207. supports:
  208. .Bl -tag -width tenletters
  209. .It Vt Follow
  210. Complete support, on input and output.
  211. .It Vt Undo
  212. For
  213. .Vt Follow
  214. objects, on input and output.
  215. .It Vt Create
  216. For
  217. .Vt Note
  218. objects, on input and output.
  219. .It Vt Accept
  220. For
  221. .Vt Follow
  222. objects, on input and output.
  223. .It Vt Like
  224. For
  225. .Vt Note
  226. objects, on input and output.
  227. .It Vt Announce
  228. For
  229. .Vt Note
  230. objects, on input and output.
  231. .It Vt Update
  232. For
  233. .Vt Person
  234. and
  235. .Vt Note
  236. objects, on input and output.
  237. .It Vt Delete
  238. Supported for
  239. .Vt Note
  240. and
  241. .Vt Tomsbtone
  242. objects on input, and for
  243. .Vt Note
  244. objects on output.
  245. .El
  246. .Pp
  247. The rest of activities and objects are dropped on input.
  248. .Pp
  249. There is partial support for
  250. .Vt OrderedCollection
  251. objects in the
  252. .Pa /outbox
  253. (with the last 20 entries of the local timeline shown). No pagination
  254. is supported. Intentionally, the
  255. .Pa /followers
  256. and
  257. .Pa /following
  258. paths return empty lists.
  259. .Ss Migrating from Mastodon
  260. User migration from different Fediverse instances is a pain in the ass
  261. that has been implemented everywhere as a kludgy afterthought. There is
  262. not much that can be done, other than importing the list of people you
  263. follow to your new
  264. .Nm
  265. account.
  266. .Pp
  267. To do this, download the user's list of accounts being followed (in CSV
  268. format) from the Mastodon web interface and execute this:
  269. .Bd -literal -offset indent
  270. awk -F, 'NR > 1 { print $1 }' /path/to/following_accounts.csv | \\
  271. xargs -n 1 snac follow $SNAC_BASEDIR $SNAC_USER
  272. .Ed
  273. .Ss Other Considerations
  274. .Nm
  275. stores all the messages it receives as JSON files, which are usually
  276. bloated and filled with redundant information. Using a filesystem with
  277. file compression enabled (like btrfs or zfs) will probably be a good
  278. choice to store the
  279. .Nm
  280. data storage into.
  281. .Sh ENVIRONMENT
  282. .Bl -tag -width Ds
  283. .It Ev DEBUG
  284. Overrides the debugging level from the server 'dbglevel' configuration
  285. variable. Set it to an integer value. The higher, the deeper in meaningless
  286. verbiage you'll find yourself into.
  287. .El
  288. .Sh EXAMPLES
  289. You want to install the
  290. .Nm
  291. Fediverse daemon in the host example.com, that is correctly configured
  292. with a valid TLS certificate and running the nginx httpd server.
  293. The service will be installed under the
  294. .Pa fedi
  295. location. Two users, walter and jessie, will be hosted in the system.
  296. Their Fediverse presence addresses will be https://example.com/fedi/walter
  297. and https://example.com/fedi/jesse, respectively. They will be known
  298. in the Fediverse as @walter@example.com and @jesse@example.com. The
  299. .Nm
  300. daemon will run as the user snacusr in the system and listen to the
  301. localhost:8001 network socket. All data will be stored in the
  302. .Pa /home/snacusr/fedidata
  303. directory.
  304. .Pp
  305. Log into the system as snacusr and execute:
  306. .Bd -literal -offset indent
  307. snac init /home/snacusr/fedidata
  308. .Ed
  309. .Pp
  310. Answer "example.com" to the host name question, "/fedi" to the path
  311. prefix question, "localhost" to the address and "8001" to the port.
  312. .Pp
  313. Create the users
  314. .Bd -literal -offset indent
  315. snac adduser /home/snacusr/fedidata walter
  316. snac adduser /home/snacusr/fedidata jesse
  317. .Ed
  318. .Pp
  319. Answer the questions with reasonable values.
  320. .Pp
  321. Execute the server:
  322. .Bd -literal -offset indent
  323. snac httpd /home/snacusr/fedidata
  324. .Ed
  325. .Pp
  326. Edit the nginx configuration and add the following snippet to the
  327. example.com server section:
  328. .Bd -literal -offset indent
  329. location /.well-known/webfinger {
  330. proxy_pass http://localhost:8001;
  331. proxy_set_header Host $http_host;
  332. }
  333. # optional
  334. location /.well-known/nodeinfo {
  335. proxy_pass http://localhost:8001;
  336. proxy_set_header Host $http_host;
  337. }
  338. location /fedi {
  339. proxy_pass http://localhost:8001;
  340. proxy_set_header Host $http_host;
  341. }
  342. .Ed
  343. .Pp
  344. Restart the nginx daemon and connect to https://example.com/fedi/walter.
  345. The empty, default screen will be shown. Enter the admin section with the
  346. credentials defined for this user. Search people, start following
  347. them, engage in arid discussions and generally enjoy the frustrating
  348. experience of Social Media.
  349. .Sh SEE ALSO
  350. .Xr snac 1 ,
  351. .Xr snac 5
  352. .Sh AUTHORS
  353. .An grunfink @grunfink@comam.es
  354. .Sh LICENSE
  355. See the LICENSE file for details.
  356. .Sh CAVEATS
  357. JSON files are fragile when modified by hand. Take care.