Only terminate PT processes that are running.
[tor.git] / scripts / maint / checkShellScripts.sh
blob0a423be29ed695ce134f3cceef965cea7be0e5f1
1 #!/usr/bin/env bash
3 # Copyright (c) 2019 The Tor Project, Inc.
4 # See LICENSE for license information
6 # checkShellScripts.sh
7 # --------------------
8 # If shellcheck is installed, check all the shell scripts that we can fix.
10 set -e
12 # Only run this script if shellcheck is installed
13 # command echoes the path to shellcheck, which is a useful diagnostic log
14 if ! command -v shellcheck; then
15 printf "%s: Install shellcheck to check shell scripts.\\n" "$0"
16 exit 0
19 # Some platforms don't have realpath
20 if command -v realpath ; then
21 HERE=$(dirname "$(realpath "$0")")
22 else
23 HERE=$(dirname "$0")
24 if [ ! -d "$HERE" ] || [ "$HERE" = "." ]; then
25 HERE=$(dirname "$PWD/$0")
28 TOPLEVEL=$(dirname "$(dirname "$HERE")")
30 # Check we actually have a tor/src directory
31 if [ ! -d "$TOPLEVEL/src" ]; then
32 printf "Error: Couldn't find src directory in expected location: %s\\n" \
33 "$TOPLEVEL/src"
34 exit 1
37 # Remove obsolete scripts generated from older versions of Tor
38 rm -f "$TOPLEVEL/contrib/dist/suse/tor.sh" "$TOPLEVEL/contrib/dist/tor.sh"
40 # Check *.sh scripts, but ignore the ones that we can't fix
41 find "$TOPLEVEL/contrib" "$TOPLEVEL/doc" "$TOPLEVEL/scripts" "$TOPLEVEL/src" \
42 -name "*.sh" \
43 -not -path "$TOPLEVEL/src/ext/*" \
44 -not -path "$TOPLEVEL/src/rust/registry/*" \
45 -exec shellcheck {} +
47 # Check scripts that aren't named *.sh
48 if [ -d "$TOPLEVEL/scripts/test" ]; then
49 shellcheck \
50 "$TOPLEVEL/scripts/test/cov-diff" \
51 "$TOPLEVEL/scripts/test/coverage"
53 if [ -e \
54 "$TOPLEVEL/contrib/dirauth-tools/nagios-check-tor-authority-cert" \
55 ]; then
56 shellcheck \
57 "$TOPLEVEL/contrib/dirauth-tools/nagios-check-tor-authority-cert"
59 if [ -e "$TOPLEVEL/contrib/client-tools/torify" ]; then
60 shellcheck "$TOPLEVEL/contrib/client-tools/torify"
62 if [ -d "$TOPLEVEL/scripts/git" ]; then
63 shellcheck "$TOPLEVEL/scripts/git/"*.git-hook