Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brew: improve formula to remove deprecated syntax #76

Merged
merged 4 commits into from
Jun 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 12 additions & 44 deletions aws-rotate-iam-keys.template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@ class AwsRotateIamKeys < Formula
homepage "https://aws-rotate-iam-keys.com"
url "${HOMEBREW_URL}"
sha256 "${HOMEBREW_SHA}"
depends_on "awscli" => :recommended
depends_on "gnu-getopt"
depends_on "jq"

head do
Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '../'))) do
url %x{git config --local --get remote.origin.url | tr -d '\n'}, using: :git
end
end
depends_on "awscli" => :recommended

def install
bin.install "src/bin/aws-rotate-iam-keys"
Expand All @@ -27,7 +21,7 @@ def install
end

def caveats
s = <<~EOS
<<~EOS
We've installed a default/global configuration file to:
#{etc}/aws-rotate-iam-keys

Expand All @@ -50,42 +44,16 @@ def caveats
EOS
end

plist_options :startup => false

def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>if ! curl -s www.google.com > /dev/null; then sleep 60; fi; cp /dev/null /tmp/#{plist_name}.log ; ( egrep '^[[:space:]]*-' ~/.aws-rotate-iam-keys 2>/dev/null || cat #{etc}/aws-rotate-iam-keys ) | while read line; do aws-rotate-iam-keys §line; done</string>
</array>
<key>StandardOutPath</key>
<string>/tmp/#{plist_name}.log</string>
<key>StandardErrorPath</key>
<string>/tmp/#{plist_name}.log</string>
<key>RunAtLoad</key>
<true/>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>23</integer>
</dict>
</dict>
</plist>
EOS
def log_path
var/"log/#{name}.log"
end
service do
run opt_bin/"aws-rotate-iam-keys"
run_type :cron
cron "23 3 * * *"
environment_variables PATH: std_service_path_env
log_path f.log_path
error_log_path f.log_path
end

test do
Expand Down