]>
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/upgrade_cli'
15 require_relative
'mastodon/email_domain_blocks_cli'
16 require_relative
'mastodon/ip_blocks_cli'
17 require_relative
'mastodon/maintenance_cli'
18 require_relative
'mastodon/version'
22 def self.exit_on_failure
?
26 desc
'media SUBCOMMAND ...ARGS', 'Manage media files'
27 subcommand
'media', Mastodon
::MediaCLI
29 desc
'emoji SUBCOMMAND ...ARGS', 'Manage custom emoji'
30 subcommand
'emoji', Mastodon
::EmojiCLI
32 desc
'accounts SUBCOMMAND ...ARGS', 'Manage accounts'
33 subcommand
'accounts', Mastodon
::AccountsCLI
35 desc
'feeds SUBCOMMAND ...ARGS', 'Manage feeds'
36 subcommand
'feeds', Mastodon
::FeedsCLI
38 desc
'search SUBCOMMAND ...ARGS', 'Manage the search engine'
39 subcommand
'search', Mastodon
::SearchCLI
41 desc
'settings SUBCOMMAND ...ARGS', 'Manage dynamic settings'
42 subcommand
'settings', Mastodon
::SettingsCLI
44 desc
'statuses SUBCOMMAND ...ARGS', 'Manage statuses'
45 subcommand
'statuses', Mastodon
::StatusesCLI
47 desc
'domains SUBCOMMAND ...ARGS', 'Manage account domains'
48 subcommand
'domains', Mastodon
::DomainsCLI
50 desc
'preview_cards SUBCOMMAND ...ARGS', 'Manage preview cards'
51 subcommand
'preview_cards', Mastodon
::PreviewCardsCLI
53 desc
'cache SUBCOMMAND ...ARGS', 'Manage cache'
54 subcommand
'cache', Mastodon
::CacheCLI
56 desc
'upgrade SUBCOMMAND ...ARGS', 'Various version upgrade utilities'
57 subcommand
'upgrade', Mastodon
::UpgradeCLI
59 desc
'email_domain_blocks SUBCOMMAND ...ARGS', 'Manage e-mail domain blocks'
60 subcommand
'email_domain_blocks', Mastodon
::EmailDomainBlocksCLI
62 desc
'ip_blocks SUBCOMMAND ...ARGS', 'Manage IP blocks'
63 subcommand
'ip_blocks', Mastodon
::IpBlocksCLI
65 desc
'maintenance SUBCOMMAND ...ARGS', 'Various maintenance utilities'
66 subcommand
'maintenance', Mastodon
::MaintenanceCLI
68 option
:dry_run, type
: :boolean
69 desc
'self-destruct', 'Erase the server from the federation'
70 long_desc
<<~LONG_DESC
71 Erase the server from the federation by broadcasting account delete
72 activities to all known other servers. This allows a "clean exit" from
73 running a Mastodon server, as it leaves next to no cache behind on
76 This command is always interactive and requires confirmation twice.
78 No local data is actually deleted, because emptying the
79 database or removing files is much faster through other, external
80 means, such as e.g. deleting the entire VPS. However, because other
81 servers will delete data about local users, but no local data will be
82 updated (such as e.g. followers), there will be a state mismatch
83 that will lead to glitches and issues if you then continue to run and use
86 So either you know exactly what you are doing, or you are starting
87 from a blank slate afterwards by manually clearing out all the local
93 prompt
= TTY
::Prompt.new
95 exit(1) unless prompt
.ask('Type in the domain of the server to confirm:', required
: true) == Rails
.configuration
.x
.local_domain
97 prompt
.warn('This operation WILL NOT be reversible. It can also take a long time.')
98 prompt
.warn('While the data won\'t be erased locally, the server will be in a BROKEN STATE afterwards.')
99 prompt
.warn('A running Sidekiq process is required. Do not shut it down until queues clear.')
101 exit(1) if prompt
.no
?('Are you sure you want to proceed?')
103 inboxes
= Account
.inboxes
105 dry_run
= options
[:dry_run] ? ' (DRY RUN)' : ''
108 prompt
.ok('It seems like your server has not federated with anything')
109 prompt
.ok('You can shut it down and delete it any time')
113 prompt
.warn('Do NOT interrupt this process...')
115 Setting
.registrations_mode
= 'none'
117 Account
.local
.without_suspended
.find_each
do |account
|
118 payload
= ActiveModelSerializers
::SerializableResource.new(
120 serializer
: ActivityPub
::DeleteActorSerializer,
121 adapter
: ActivityPub
::Adapter
124 json
= Oj
.dump(ActivityPub
::LinkedDataSignature.new(payload
).sign!
(account
))
126 unless options
[:dry_run]
127 ActivityPub
::DeliveryWorker.push_bulk(inboxes
) do |inbox_url
|
128 [json
, account
.id
, inbox_url
]
137 prompt
.ok("Queued #{inboxes.size * processed} items into Sidekiq for #{processed} accounts#{dry_run}")
138 prompt
.ok('Wait until Sidekiq processes all items, then you can shut everything down and delete the data')
139 rescue TTY
::Reader::InputInterrupt
143 map
%w(--version -v
) => :version
145 desc
'version', 'Show version'
147 say(Mastodon
::Version.to_s
)
This page took 0.151696 seconds and 4 git commands to generate.