-
Notifications
You must be signed in to change notification settings - Fork 0
/
sss-utils.sh
executable file
·187 lines (154 loc) · 4.57 KB
/
sss-utils.sh
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
#!/bin/bash
_SSSSCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
sss-rename-codefile() {
if should-print-help $@
then
echo "Rename codefile and replaces its name in all files"
echo "Usage:"
echo "$0 OLDNAME NEWNAME"
echo ""
return 0
fi
local OLDNAME=$1
local NEWNAME=$2
local NOSRC_OLDNAME=${OLDNAME/#src\//}
local NOSRC_NEWNAME=${NEWNAME/#src\//}
local MAKE_SED="s/${OLDNAME//\//\\\/}/${NEWNAME//\//\\\/}/g"
local CODE_SED="s/${NOSRC_OLDNAME//\//\\\/}/${NOSRC_NEWNAME//\//\\\/}/g"
echo "Renaming $OLDNAME to $NEWNAME"
git mv $OLDNAME $NEWNAME
echo "Replacing $OLDNAME for $NEWNAME in *.am"
find . -type f -name "*.am" -exec sed -i $MAKE_SED {} +
echo "Replacing $NOSRC_OLDNAME for $NOSRC_NEWNAME in *.c and *.h"
find . -type f -name "*.c" -exec sed -i $CODE_SED {} +
find . -type f -name "*.h" -exec sed -i $CODE_SED {} +
git commit -a -m "Rename $(basename $OLDNAME) to $(basename $NEWNAME)"
}
sss-brew-repo() {
if should-print-help $@
then
echo "Prepare brew repository with newest packages"
echo "Usage:"
echo "$0 RHEL-VERSION"
echo ""
return 0
fi
local RHEL=$1
local pkgnames="libtalloc libtevent libtdb libldb ding-libs"
local tag=$RHEL-temp-override
local repo=$RHEL-build
for pkg in $pkgnames; do
local latest=$(brew -q latest-pkg rhel-7.3-candidate $pkg 2>/dev/null | awk '{print $1}')
brew tag-pkg $tag $latest
done
brew wait-repo $repo --build $latest
}
sss-brew-rpms-fetch() {
if should-print-help $@
then
echo "Download SSSD RPMs from brew build, located at \$BREW_URL ($BREW_URL)"
echo "Usage:"
echo "$0 URL-TO-ANY-PACKAGE"
echo ""
return 0
fi
local URL=$1
local PATTERN="^\($BREW_URL/brewroot/work/tasks/[0-9]*/[0-9]*/\)[^0-9]*\(.*\)\.\(.*\)\.rpm$"
for rpm in $(< "$_SSSSCRIPTDIR/rpms_arch"); do
wget $(echo $URL | sed 's|'$PATTERN'|\1'$rpm'-\2.\3.rpm|')
done
for rpm in $(< "$_SSSSCRIPTDIR/rpms_noarch"); do
wget $(echo $URL | sed 's|'$PATTERN'|\1'$rpm'-\2.noarch.rpm|')
done
}
sss-brew-rpms-push() {
if should-print-help $@
then
echo "Push SSSD RPMs into fedorapeople scratch build"
echo "Usage:"
echo "$0 BUILD-NAME"
echo ""
return 0
fi
local SCRATCH="public_html/scratch/${1}"
ssh fedorapeople.org "rm -frv $SCRATCH ; mkdir -p $SCRATCH"
scp *.rpm fedorapeople.org:$SCRATCH
}
sss-brew-scratch-build() {
if should-print-help-allow-empty $@
then
echo "Issue an SSSD scratch build"
echo "Usage:"
echo "$0 [RHEL-VERSION=current-branch]"
echo ""
return 0
fi
local BRANCH="$(mygit-current-branch)"
local SRPM=$(rhpkg srpm 2> /dev/null | tail -n 2 | sed 's/^Wrote: //')
local RHEL=${1-$BRANCH}
rhpkg --release $RHEL scratch-build --srpm $SRPM
}
sss-run() {
if should-print-help-allow-empty $@
then
echo "Run SSSD in interactive mode with debug level 0x3ff0"
echo "Usage:"
echo "$0 ADDITIONAL-SSSD-ARGS"
echo ""
return 0
fi
rm -f /var/lib/sss/db/* /var/log/sssd/*
sssd -i -d 0x3ff0 ${1-}
}
sss-run-ci() {
if should-print-help-allow-empty $@
then
echo "Run SSSD Continuous Integration test on current branch"
echo "Usage:"
echo "$0"
echo ""
return 0
fi
git push ci HEAD:master
}
sss-talloc-report() {
if should-print-help $@
then
echo "Generate a talloc report from SSSD binary."
echo "Usage:"
echo "$0 SSSD-PROCESS [FILENAME/tmp/sssd.talloc/@process.@timestamp]"
echo ""
return 0
fi
local TIME=`date +"%s"`
local PROGRAM=$1
local FILE=$2
local DIR="/tmp/sssd.talloc"
local PROCESS=""
if [ -z "$FILE" ]
then
mkdir -p $DIR
FILE="$DIR/$PROGRAM.$TIME"
fi
pgrep $PROGRAM &> /dev/null
if [ $? -eq 0 ];
then
PROCESS=`pgrep $PROGRAM | head -n 1`
else
echo "No such process."
return 1
fi
echo "Attaching GDB to $PROGRAM with PID $PROCESS"
sudo gdb -quiet -batch -p $PROCESS \
-ex "set \$file = (FILE*)fopen(\"$FILE\", \"w+\")" \
-ex 'call talloc_enable_null_tracking()' \
-ex 'call talloc_report_full(0, $file)' \
-ex 'detach' \
-ex 'quit' &> /dev/null
if [ $? -eq 0 ];
then
echo "Talloc report generated to: $FILE"
else
echo "Unable to generate talloc report."
fi
}