]>
cat aescling's git repositories - mastodon.git/blob - lib/cli.rb
1 # frozen_string_literal: true
4 require_relative
'mastodon/media_cli'
5 require_relative
'mastodon/emoji_cli'
6 require_relative
'mastodon/accounts_cli'
7 require_relative
'mastodon/feeds_cli'
8 require_relative
'mastodon/search_cli'
9 require_relative
'mastodon/settings_cli'
10 require_relative
'mastodon/statuses_cli'
11 require_relative
'mastodon/domains_cli'
12 require_relative
'mastodon/preview_cards_cli'
13 require_relative
'mastodon/cache_cli'
14 require_relative
'mastodon/version'
18 def self.exit_on_failure
?
22 desc
'media SUBCOMMAND ...ARGS', 'Manage media files'
23 subcommand
'media', Mastodon
::MediaCLI
25 desc
'emoji SUBCOMMAND ...ARGS', 'Manage custom emoji'
26 subcommand
'emoji', Mastodon
::EmojiCLI
28 desc
'accounts SUBCOMMAND ...ARGS', 'Manage accounts'
29 subcommand
'accounts', Mastodon
::AccountsCLI
31 desc
'feeds SUBCOMMAND ...ARGS', 'Manage feeds'
32 subcommand
'feeds', Mastodon
::FeedsCLI
34 desc
'search SUBCOMMAND ...ARGS', 'Manage the search engine'
35 subcommand
'search', Mastodon
::SearchCLI
37 desc
'settings SUBCOMMAND ...ARGS', 'Manage dynamic settings'
38 subcommand
'settings', Mastodon
::SettingsCLI
40 desc
'statuses SUBCOMMAND ...ARGS', 'Manage statuses'
41 subcommand
'statuses', Mastodon
::StatusesCLI
43 desc
'domains SUBCOMMAND ...ARGS', 'Manage account domains'
44 subcommand
'domains', Mastodon
::DomainsCLI
46 desc
'preview_cards SUBCOMMAND ...ARGS', 'Manage preview cards'
47 subcommand
'preview_cards', Mastodon
::PreviewCardsCLI
49 desc
'cache SUBCOMMAND ...ARGS', 'Manage cache'
50 subcommand
'cache', Mastodon
::CacheCLI
52 option
:dry_run, type
: :boolean
53 desc
'self-destruct', 'Erase the server from the federation'
54 long_desc
<<~LONG_DESC
55 Erase the server from the federation by broadcasting account delete
56 activities to all known other servers. This allows a "clean exit" from
57 running a Mastodon server, as it leaves next to no cache behind on
60 This command is always interactive and requires confirmation twice.
62 No local data is actually deleted, because emptying the
63 database or removing files is much faster through other, external
64 means, such as e.g. deleting the entire VPS. However, because other
65 servers will delete data about local users, but no local data will be
66 updated (such as e.g. followers), there will be a state mismatch
67 that will lead to glitches and issues if you then continue to run and use
70 So either you know exactly what you are doing, or you are starting
71 from a blank slate afterwards by manually clearing out all the local
77 prompt
= TTY
::Prompt.new
79 exit(1) unless prompt
.ask('Type in the domain of the server to confirm:', required
: true) == Rails
.configuration
.x
.local_domain
81 prompt
.warn('This operation WILL NOT be reversible. It can also take a long time.')
82 prompt
.warn('While the data won\'t be erased locally, the server will be in a BROKEN STATE afterwards.')
83 prompt
.warn('A running Sidekiq process is required. Do not shut it down until queues clear.')
85 exit(1) if prompt
.no
?('Are you sure you want to proceed?')
87 inboxes
= Account
.inboxes
89 dry_run
= options
[:dry_run] ? ' (DRY RUN)' : ''
92 prompt
.ok('It seems like your server has not federated with anything')
93 prompt
.ok('You can shut it down and delete it any time')
97 prompt
.warn('Do NOT interrupt this process...')
99 Account
.local
.without_suspended
.find_each
do |account
|
100 payload
= ActiveModelSerializers
::SerializableResource.new(
102 serializer
: ActivityPub
::DeleteActorSerializer,
103 adapter
: ActivityPub
::Adapter
106 json
= Oj
.dump(ActivityPub
::LinkedDataSignature.new(payload
).sign!
(account
))
108 unless options
[:dry_run]
109 ActivityPub
::DeliveryWorker.push_bulk(inboxes
) do |inbox_url
|
110 [json
, account
.id
, inbox_url
]
119 prompt
.ok("Queued #{inboxes.size * processed} items into Sidekiq for #{processed} accounts#{dry_run}")
120 prompt
.ok('Wait until Sidekiq processes all items, then you can shut everything down and delete the data')
121 rescue TTY
::Reader::InputInterrupt
125 map
%w(--version -v
) => :version
127 desc
'version', 'Show version'
129 say(Mastodon
::Version.to_s
)
This page took 0.101404 seconds and 4 git commands to generate.