Skip to content

Commit ac54310

Browse files
committed
Cleaned up indentation and comments in shell scripts
Signed-off-by: Ole Herman Schumacher Elgesem <[email protected]>
1 parent 9a9b165 commit ac54310

File tree

8 files changed

+77
-79
lines changed

8 files changed

+77
-79
lines changed

generator/_scripts/_publish.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ cd $WRKDIR
1313
find documentation/generator/pages -name "*.markdown" | xargs rm
1414
cp `find documentation/generator/pages -name "*.*"` documentation/generator/_site
1515
if [ ! -d documentation/generator/_site ]; then
16-
exit 1
16+
exit 1
1717
fi
1818

1919
OUTPUT=$WRKDIR/output
2020
mkdir -p $OUTPUT
2121

22-
# replace absolute style and script links with relative ones. This way, no
22+
# Replace absolute style and script links with relative ones. This way, no
2323
# matter how docs will be served (on https://docs.cfengine.com/docs/3.18/ or
2424
# http://buildcache.cfengine.com/packages/build-documentation-pr/jenkins-pr-pipeline-7204/output/_site/),
2525
# these links will still be valid.
2626
cd documentation/generator/_site
2727
for source in *.html;
2828
do
29-
sed -i "s/<base href\([^>]*\)>/<!-- base href\1 -->/
30-
s/<link href='.*assets\(.*\)>/<link href='assets\1>/
31-
s/<script src='.*assets\(.*\)>/<script src='assets\1>/" $source
29+
sed -i "s/<base href\([^>]*\)>/<!-- base href\1 -->/
30+
s/<link href='.*assets\(.*\)>/<link href='assets\1>/
31+
s/<script src='.*assets\(.*\)>/<script src='assets\1>/" $source
3232
done
3333
cd -
3434

@@ -43,10 +43,10 @@ cd documentation/generator/_site
4343
# in the downloaded archive
4444
for source in *.html;
4545
do
46-
sed -i "s/<select/<!-- select/
47-
s/<\/select>/<\/select -->/
48-
s/<form/<!-- from/
49-
s/<\/form>/<\/form -->/" $source
46+
sed -i "s/<select/<!-- select/
47+
s/<\/select>/<\/select -->/
48+
s/<form/<!-- from/
49+
s/<\/form>/<\/form -->/" $source
5050
done
5151
cd ..
5252
tar -czf $OUTPUT/$ARCHIVE_FILE.tar.gz _site

generator/_scripts/_run_jekyll.sh

+7-8
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ cd $WRKDIR/documentation/generator
2121
# so instead of set -x we just echo each command ourselves
2222
set +x
2323
if [ -e "/home/jenkins/.rvm/scripts/rvm" ]; then
24-
echo "+ /home/jenkins/.rvm/scripts/rvm"
25-
source /home/jenkins/.rvm/scripts/rvm
24+
echo "+ /home/jenkins/.rvm/scripts/rvm"
25+
source /home/jenkins/.rvm/scripts/rvm
2626
elif [ -e "$HOME/.rvm/scripts/rvm" ]; then
27-
echo "+ $HOME/.rvm/scripts/rvm"
28-
source $HOME/.rvm/scripts/rvm
27+
echo "+ $HOME/.rvm/scripts/rvm"
28+
source $HOME/.rvm/scripts/rvm
2929
else
3030
echo "ERROR: I couldn't source rvm from '/home/jenkins/.rvm/scripts/rvm' or '\$HOME/.rvm/scripts/rvm', probably jekyll won't work"
3131
fi
@@ -38,16 +38,15 @@ echo "*********************************************************" >> $WRKDIR/outp
3838
set -x
3939
jekyll
4040
if [ "$?" -gt "0" ]; then
41-
exit 1;
41+
exit 1;
4242
fi
4343

4444
$WRKDIR/documentation/generator/_scripts/cfdoc_postprocess.py "$@"
4545
if [ "$?" -gt "0" ]; then
46-
exit 2;
46+
exit 2;
4747
fi
4848

4949
$WRKDIR/documentation/generator/_scripts/_create_pdf.sh
5050
if [ "$?" -gt "0" ]; then
51-
exit 3;
51+
exit 3;
5252
fi
53-

generator/_scripts/bootstrap-build.sh

+18-18
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22

33
usage()
44
{
5-
echo "Usage: $0 [WORKDIR] [BRANCH]
5+
echo "Usage: $0 [WORKDIR] [BRANCH]
66
77
WORKDIR :: Defaults to current working directory
88
BRANCH :: Branch to build (defaults to currently checked out branch in current working directory)"
99

1010
}
1111

1212
case $# in
13-
"0" )
14-
echo "No arguments supplied"
15-
export WRKDIR="$(pwd)"
16-
BRANCH="$(git symbolic-ref --quiet --short HEAD)"
17-
;;
18-
"1" )
19-
export WRKDIR=$1
20-
BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)"
21-
;;
22-
"2" )
23-
export WRKDIR=$1
24-
BRANCH="$2"
25-
;;
26-
* )
27-
echo "Error: Too many arguments"
28-
usage
29-
exit;;
13+
"0" )
14+
echo "No arguments supplied"
15+
export WRKDIR="$(pwd)"
16+
BRANCH="$(git symbolic-ref --quiet --short HEAD)"
17+
;;
18+
"1" )
19+
export WRKDIR=$1
20+
BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)"
21+
;;
22+
"2" )
23+
export WRKDIR=$1
24+
BRANCH="$2"
25+
;;
26+
* )
27+
echo "Error: Too many arguments"
28+
usage
29+
exit;;
3030
esac
3131

3232
echo "Set WRKDIR=$WRKDIR"

generator/_scripts/starter_pack-build-docs.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ $WRKDIR/documentation/generator/_scripts/cfdoc_bootstrap.py master
1414
if dpkg --get-selections | grep -q "^cfengine-nova-hub[[:space:]]*install$" >/dev/null; then
1515
echo Found cfengine-nova-hub package installed, skipping build
1616
else
17-
echo Did not find package cfengine-nova-hub installed, trying to build from source
18-
# Prepare core for syntax docs
19-
cd /northern.tech/cfengine/core
20-
./configure
21-
make
17+
echo Did not find package cfengine-nova-hub installed, trying to build from source
18+
# Prepare core for syntax docs
19+
cd /northern.tech/cfengine/core
20+
./configure
21+
make
2222
fi
2323

2424
export WRKDIR=/northern.tech/cfengine

generator/build/install.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ curl -O https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installe
4949
curl -O https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer.asc
5050

5151
if gpg2 --verify rvm-installer.asc; then
52-
bash rvm-installer --autolibs=read-fail --ignore-dotfiles stable
52+
bash rvm-installer --autolibs=read-fail --ignore-dotfiles stable
5353
else
54-
echo "Ruby Version Manager signature check fail."
55-
echo "Github is hacked, or trying to hack us, or our script is wrong. Aborting everything"
56-
exit 1
54+
echo "Ruby Version Manager signature check fail."
55+
echo "Github is hacked, or trying to hack us, or our script is wrong. Aborting everything"
56+
exit 1
5757
fi
5858

5959
# rvm commands are insane scripts which pollut output

generator/build/latest_nightly.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ BUILDCACHE_URL="${1:?undefined}" # usually http://buildcache.cfengine.com/packag
55
GREP_EXPR="${2:?undefined}" # usually jenkins-master-nightly-pipeline
66

77
curl --silent "$BUILDCACHE_URL" | grep "$GREP_EXPR" | sed -r 's_.*<a href="([^"/]*)/">.*_\1_' | sort -rn | while read -r build; do
8-
# $build is something like jenkins-master-nightly-pipeline-962
9-
# verify that it has a deb file
10-
url="$BUILDCACHE_URL/$build/PACKAGES_HUB_x86_64_linux_ubuntu_16/"
11-
if curl --silent "$url" | grep -qF '.deb</a>'; then
12-
echo "$build"
13-
break
14-
fi
8+
# $build is something like jenkins-master-nightly-pipeline-962
9+
# verify that it has a deb file
10+
url="$BUILDCACHE_URL/$build/PACKAGES_HUB_x86_64_linux_ubuntu_16/"
11+
if curl --silent "$url" | grep -qF '.deb</a>'; then
12+
echo "$build"
13+
break
14+
fi
1515
done

generator/build/main.sh

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/bash
22

33
if [ "$#" != 4 ]; then
4-
echo "Pass 4 args, please:"
5-
echo BRANCH
6-
echo PACKAGE_JOB
7-
echo PACKAGE_UPLOAD_DIRECTORY
8-
echo PACKAGE_BUILD
9-
exit 1
4+
echo "Pass 4 args, please:"
5+
echo BRANCH
6+
echo PACKAGE_JOB
7+
echo PACKAGE_UPLOAD_DIRECTORY
8+
echo PACKAGE_BUILD
9+
exit 1
1010
fi
1111

1212
export BRANCH=$1
@@ -29,30 +29,30 @@ export WRKDIR=`pwd`
2929
cd $WRKDIR/documentation/generator
3030

3131

32-
### download CFEngine ###
32+
### Download CFEngine:
3333

3434
# c https://github.com/cfengine/misc/blob/master/vagrant_quickstart/build.sh
3535

3636
function fetch_file() {
37-
# $1 -- URL to fetch
38-
# $2 -- destination
39-
# $3 -- number of tries (with 10s pauses) [optional, default=1]
40-
local target="$1"
41-
local destination="$2"
42-
local tries=1
43-
if [ $# -gt 2 ]; then
44-
tries="$3"
45-
fi
46-
local success=1 # 1 means False in bash, 0 means True
47-
set +e
48-
for i in `seq 1 $tries`; do
49-
wget "$target" -O "$destination" && success=0 && break
50-
if [ $i -lt $tries ]; then
51-
sleep 10s
37+
# $1 -- URL to fetch
38+
# $2 -- destination
39+
# $3 -- number of tries (with 10s pauses) [optional, default=1]
40+
local target="$1"
41+
local destination="$2"
42+
local tries=1
43+
if [ $# -gt 2 ]; then
44+
tries="$3"
5245
fi
53-
done
54-
set -e
55-
return $success
46+
local success=1 # 1 means False in bash, 0 means True
47+
set +e
48+
for i in `seq 1 $tries`; do
49+
wget "$target" -O "$destination" && success=0 && break
50+
if [ $i -lt $tries ]; then
51+
sleep 10s
52+
fi
53+
done
54+
set -e
55+
return $success
5656
}
5757

5858
set -ex

generator/build/run.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ if ! buildah inspect docs-revamp-22 >/dev/null 2>&1; then
77
buildah build-using-dockerfile -t docs-revamp-22 documentation/generator/build
88
fi
99

10-
# current path must have the following repos cloned:
10+
# Current path must have the following repos cloned:
1111
# * core (used for changelog, examples)
1212
# * nova (used for changelog)
1313
# * enterprise (used for changelog)
1414
# * masterfiles (used to document masterfies)
1515
# * documentation (this repo)
1616

17-
# these env vars must be defined
17+
# These env vars must be defined:
1818
true "${BRANCH?undefined}"
1919
true "${PACKAGE_JOB?undefined}"
2020
true "${PACKAGE_UPLOAD_DIRECTORY?undefined}"
@@ -24,4 +24,3 @@ c=$(buildah from -v $PWD:/nt docs-revamp-22)
2424
trap "buildah run $c bash -c 'sudo chmod -R a+rwX /nt'; buildah rm $c >/dev/null" EXIT
2525
buildah run $c bash -x documentation/generator/build/main.sh $BRANCH $PACKAGE_JOB $PACKAGE_UPLOAD_DIRECTORY $PACKAGE_BUILD
2626
buildah run $c bash -x documentation/generator/_scripts/_publish.sh $BRANCH
27-

0 commit comments

Comments
 (0)