-
Notifications
You must be signed in to change notification settings - Fork 21
/
etc_ssl.run
executable file
·60 lines (55 loc) · 1.92 KB
/
etc_ssl.run
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
#!/bin/bash -e
# vim:syntax=sh
#
# Copyright (c) 2010,2013 SUSE Linux Products GmbH
# Copyright (c) 2020 SUSE LLC
# Author: Ludwig Nussel
#
# update /etc/ssl/certs for compatibility with legacy applications
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301,
# USA.
#
[ -d "$statedir" ]
etccertsdir="${destdir}/etc/ssl/certs"
pemdir="$statedir/pem"
help_and_exit()
{
cat <<-EOF
USAGE: $0 [OPTIONS]
OPTIIONS:
--verbose, -v verbose output
--fresh, -f start from scratch
--help, -h this screen
EOF
exit 0
}
case "$1" in
-v|--verbose) verbose='-v'; shift ;;
-f|--fresh) fresh='-f'; shift ;;
-h|--help) help_and_exit ;;
-*) echo "invalid option: $1" >&2; exit 1 ;;
esac
install -d -m 0755 "${destdir}$pemdir"
trust extract --purpose=server-auth --filter=ca-anchors --format=pem-directory-hash -f "${destdir}$pemdir"
# fix up /etc/ssl/certs if it's not a link pointing to /var/lib/ca-certificates/pem
if ! [ -L "$etccertsdir" -a "`readlink $etccertsdir`" = "../..$pemdir" ]; then
echo "Warning: $etccertsdir needs to be a link to ../..$pemdir, fixing" >&2
if [ -d "$etccertsdir" ]; then
mv -Tv --backup=numbered "$etccertsdir" "$etccertsdir.old"
fi
install -d -m 0755 "${etccertsdir%/*}"
ln -Tsv --backup=numbered "../..$pemdir" "$etccertsdir"
fi