Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Improve the token generator #117

Merged
merged 1 commit into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion build/vanagon/components/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
'cp Rakefile /opt/voxpupuli/webhook/',
'cp ../postinst.sh /opt/voxpupuli/webhook/bin/',
'cp ../generate_token /opt/voxpupuli/webhook/bin/',
'ln -s /opt/voxpupuli/webhook/bin/generate_token /usr/local/bin/generate_token',
'cp /opt/voxpupuli/webhook/config/config.yml.example /etc/voxpupuli/webhook.yaml',
"echo 'App installed'"
]
Expand Down
14 changes: 10 additions & 4 deletions resources/generate_token
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#!/usr/bin/env bash

echo "This command will generate an API token for use with Puppet Webhook and will replace any existing token you currently have"

read -p "are you sure? (y/N)" -n 1 -r
echo
read -p "are you sure? (y/N) " -n 1 -r
echo
echo

if [[ $REPLY =~ ^[Yy]$ ]]
then
export SINATRA_EN=production
export SINATRA_ENV=production
export RUBYLIB=/opt/voxpupuli/webhook/lib/ruby:/opt/voxpupuli/webhook:/opt/voxpupuli/webhook/app/models
export GEM_HOME=/opt/voxpupuli/webhook/lib/ruby/gems/2.6.0
export GEM_PATH=$GEM_HOME
export LD_PATH=/opt/voxpupuli/webhook/lib
export PATH=/opt/voxpupuli/webhook/bin:$PATH
cd /opt/voxpupuli/webhook && bin/bundle exec rake db:generate_token --trace
export RUBYOPT="-W0"
output=`cd /opt/voxpupuli/webhook && bin/bundle exec rake db:generate_token`

echo "Your new API token is: ${output}"
echo
echo "Be sure to save this somewhere as you won't be able to retrieve it again without generating a new token!"
fi