This file is indexed.

/usr/bin/sup-config is in sup-mail 0.22.1-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#!/usr/bin/ruby

$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])

require 'highline/import'
require 'trollop'
require "sup"

$opts = Trollop::options do
  version "sup-config (sup #{Redwood::VERSION})"
  banner <<EOS
Interactive configuration tool for Sup. Won't destroy existing
configuration.

Usage:
  sup-config

No options.
EOS
end

def axe q, default=nil
  question = if default && !default.empty?
               "#{q} (enter for \"#{default}\"): "
             else
               "#{q}: "
             end
  ans = ask question
  ans.empty? ? default : ans.to_s
end

def axe_yes q, default="n"
  axe(q, default) =~ /^y|yes$/i
end

def build_cmd cmd
  (ENV["RUBY_INVOCATION"] ? ENV["RUBY_INVOCATION"] + " " : "") + File.join(File.dirname($0), cmd)
end

def add_source
  require "sup/util/uri"

  type = nil

  say "Ok, adding a new source."
  choose do |menu|
    menu.prompt = "What type of mail source is it? "
    menu.choice("mbox file") { type = :mbox }
    menu.choice("maildir directory") { type = :maildir }
    menu.choice("Get me out of here!") { return }
  end

  while true do
    say "Ok, now for the details."

    default_labels, components = case type
    when :mbox
      $last_fn ||= ENV["MAIL"]
      fn = axe "What's the full path to the mbox file?", $last_fn
      return if fn.nil? || fn.empty?

      $last_fn = fn
      [Redwood::MBox.suggest_labels_for(fn),
       { :scheme => "mbox", :path => fn }]
    when :maildir
      $last_fn ||= ENV["MAIL"]
      fn = axe "What's the full path to the maildir directory?", $last_fn
      return if fn.nil? || fn.empty?

      $last_fn = fn
      [Redwood::Maildir.suggest_labels_for(fn),
       { :scheme => "maildir", :path => fn }]
    end

    uri = begin
      Redwood::Util::Uri.build components
    rescue URI::Error => e
      say "Whoopsie! I couldn't build a URI from that: #{e.message}"
      if axe_yes("Try again?") then next else return end
    end

    say "I'm going to add this source: #{uri}"
    unless axe("Does that look right?", "y") =~ /^y|yes$/i
      if axe_yes("Try again?") then next else return end
    end

    usual = axe_yes "Does this source ever receive new messages?", "y"
    archive = usual ? axe_yes("Should new messages be automatically archived? (I.e. not appear in your inbox, though still be accessible via search.)") : false

    sync_back = (type == :maildir) ? axe_yes("Should the original Maildir messages be modified to reflect changes like read status, starred messages, etc.?", "y") : false

    labels_str = axe("Enter any labels to be automatically added to all messages from this source, separated by spaces (or 'none')", default_labels.join(","))

    labels = if labels_str =~ /^\s*none\s*$/i
      nil
    else
      labels_str.split(/\s+/)
    end

    cmd = build_cmd "sup-add"
    cmd += " --unusual" unless usual
    cmd += " --archive" if archive
    cmd += " --no-sync-back" unless sync_back
    cmd += " --labels=#{labels.join(',')}" if labels && !labels.empty?
    cmd += " #{uri}"

    puts "Ok, trying to run \"#{cmd}\"..."

    system cmd
    if $?.success?
      say "Great! Added!"
      break
    else
      say "Rats, that failed. You may have to do it manually."
      if axe_yes("Try again?") then next else return end
    end
  end
end

$terminal.wrap_at = :auto
Redwood::start
index = Redwood::Index.init
Redwood::SourceManager.load_sources

say <<EOS
Howdy neighbor! This here's sup-config, ready to help you jack in to
the next generation of digital cyberspace: the text-based email
program. Get ready to be the envy of everyone in your internets
with your amazing keyboarding skills! Jump from email to email with
nary a click of the mouse!

Just answer these simple questions and you'll be on your way.

EOS

account = $config[:accounts][:default]

name = axe "What's your name?", account[:name]
email = axe "What's your (primary) email address?", account[:email]

say "Ok, your from header will look like this:"
say "  From: #{name} <#{email}>"

say "\nDo you have any alternate email addresses that also receive email?"
say "If so, enter them now, separated by spaces."
alts = axe("Alternate email addresses", account[:alternates].join(" ")).split(/\s+/)

sigfn = axe "What file contains your signature?", account[:signature]
editor = axe "What editor would you like to use?", $config[:editor]

time_mode = axe "Would like to display time in 12h (type 12h) or in 24h (type 24h)?", $config[:time_mode]

$config[:accounts][:default][:name] = name
$config[:accounts][:default][:email] = email
$config[:accounts][:default][:alternates] = alts
$config[:accounts][:default][:signature] = sigfn
$config[:editor] = editor
$config[:time_mode] = time_mode

done = false
until done
  say "\nNow, we'll tell Sup where to find all your email."
  Redwood::SourceManager.load_sources
  say "Current sources:"
  if Redwood::SourceManager.sources.empty?
    say "  No sources!"
  else
    Redwood::SourceManager.sources.each { |s| puts "* #{s}" }
  end

  say "\n"
  choose do |menu|
    menu.prompt = "Your wish? "
    menu.choice("Add a new source.") { add_source }
    menu.choice("Done adding sources!") { done = true }
  end
end

say "\nSup needs to know where to store your sent messages."
say "Only sources capable of storing mail will be listed.\n\n"

Redwood::SourceManager.load_sources
if Redwood::SourceManager.sources.empty?
  say "\nUsing the default sup://sent, since you haven't configured other sources yet."
  $config[:sent_source] = 'sup://sent'
else
  # this handles the event that source.yaml already contains the SentLoader
  # source.
  have_sup_sent = false

  choose do |menu|
    menu.prompt = "Store my sent mail in? "

    menu.choice('Default (an mbox in ~/.sup, aka sup://sent)') { $config[:sent_source] = 'sup://sent'} unless have_sup_sent

    valid_sents = Redwood::SourceManager.sources.each do |s|
      have_sup_sent = true if s.to_s.eql?('sup://sent')
      menu.choice(s.to_s) { $config[:sent_source] = s.to_s } if s.respond_to? :store_message
    end
  end
end

Redwood::save_yaml_obj $config, Redwood::CONFIG_FN, false, true

say "Ok, I've saved you up a nice lil' #{Redwood::CONFIG_FN}."

say <<EOS

The final step is to import all your messages into the Sup index.
Depending on how many messages are in the sources, this could take
quite a while.

EOS

if axe_yes "Run sup-sync to import all messages now?"
  while true
    cmd = build_cmd("sup-sync") + " --all-sources"
    puts "Ok, trying to run \"#{cmd}\"..."
    system cmd
    if $?.success?
      say "Great! It worked!"
      break
    else
      say "Rats, that failed. You may have to do it manually."
      if axe_yes("Try again?") then next else break end
    end
  end
end

index.load

say <<EOS

Okee doke, you've got yourself an index of #{index.size} messages. Looks
like you're ready to jack in to cyberspace there, cowboy.

Just one last command:

  #{build_cmd "sup"}

Have fun!
EOS