forked from Katello/katello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset-oauth
executable file
·31 lines (25 loc) · 1.14 KB
/
reset-oauth
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
#!/bin/bash
if [ $1 ]; then
SECRET=$1
else
SECRET=`openssl rand -base64 24 | cut -c1-24`
fi
sed -i "s;\(.*oauth_secret.*:\).*;\1 $SECRET;g" /etc/katello/katello.yml
CP_CONF=/etc/candlepin/candlepin.conf
if [ -f $CP_CONF ]; then
if ( ! grep -q "candlepin.auth.oauth.enabled" $CP_CONF ); then
echo "candlepin.auth.oauth.enabled = true" >> $CP_CONF
else
sed -i "s;candlepin.auth.oauth.enabled.*;candlepin.auth.oauth.enabled = true;" $CP_CONF
fi
CP_LINE="candlepin.auth.oauth.consumer.katello.secret = $SECRET"
if ( ! grep -q "candlepin.auth.oauth.consumer." $CP_CONF); then
echo $CP_LINE >> $CP_CONF
else
sed -i "s;^\(candlepin.auth.oauth.consumer.katello.*=\).*;$CP_LINE;" /etc/candlepin/candlepin.conf
fi
fi
test -f /etc/pulp/server.conf && sed -i "s;.*oauth_secret:.*;oauth_secret: $SECRET;" /etc/pulp/server.conf
test -f /etc/pulp/server.conf && sed -i "s;.*oauth_key:.*;oauth_key: katello;" /etc/pulp/server.conf
test -f ../config/katello.yml && sed -i "s;\(.*oauth_secret.*:\).*;\1 $SECRET;g" ../config/katello.yml
echo "Don't forget to restart tomcat6, pulp-server and katello if applicable. (service <thing> restart)"