summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Volkov <av903u@att.com>2018-10-24 10:17:28 -0700
committerAndrey Volkov <av903u@att.com>2018-10-24 11:43:05 -0700
commit55d34437ad6399b62b68aba1cdd35ca42e260641 (patch)
tree4fd74fc693a86b10f376df1f9754e17b625d830c
parentb80214540c0d12caa2286083773647b26f2f67b2 (diff)
Add shellcheck
-rw-r--r--Makefile17
-rwxr-xr-xassets/update_mirror_debian.sh75
-rwxr-xr-xassets/update_mirror_ubuntu.sh36
3 files changed, 35 insertions, 93 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..5ee4e38
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,17 @@
1# Copyright 2018 The Openstack-Helm Authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15.PHONY: lint
16lint:
17 shellcheck assets/*.sh
diff --git a/assets/update_mirror_debian.sh b/assets/update_mirror_debian.sh
deleted file mode 100755
index 1523fe3..0000000
--- a/assets/update_mirror_debian.sh
+++ /dev/null
@@ -1,75 +0,0 @@
1#! /usr/bin/env bash
2set -e
3
4# Automate the initial creation and update of a Debian package mirror in aptly
5
6# The variables (as set below) will create a mirror of the Debian jessie repo
7# with the main and update components. If you do mirror these, you'll want to
8# include "deb http://security.debian.org jessie/updates main" in your sources.list
9# file or mirror it similarly as done below to keep up with security updates.
10
11DEBIAN_RELEASE=stretch
12UPSTREAM_URL="http://deb.debian.org/debian/"
13COMPONENTS=( main )
14REPOS=( ${DEBIAN_RELEASE} ${DEBIAN_RELEASE}-updates )
15
16# Create repository mirrors if they don't exist
17set +e
18for component in ${COMPONENTS[@]}; do
19 for repo in ${REPOS[@]}; do
20 aptly mirror list -raw | grep "^${repo}$"
21 if [[ $? -ne 0 ]]; then
22 echo "Creating mirror of ${repo} repository."
23 aptly mirror create \
24 -architectures=amd64 ${repo} ${UPSTREAM_URL} ${repo} ${component}
25 fi
26 done
27done
28set -e
29
30# Update all repository mirrors
31for component in ${COMPONENTS[@]}; do
32 for repo in ${REPOS[@]}; do
33 echo "Updating ${repo} repository mirror.."
34 aptly mirror update ${repo}
35 done
36done
37
38# Create snapshots of updated repositories
39for component in ${COMPONENTS[@]}; do
40 for repo in ${REPOS[@]}; do
41 echo "Creating snapshot of ${repo} repository mirror.."
42 SNAPSHOTARRAY+="${repo}-`date +%Y%m%d%H` "
43 aptly snapshot create ${repo}-`date +%Y%m%d%H` from mirror ${repo}
44 done
45done
46
47echo ${SNAPSHOTARRAY[@]}
48
49# Merge snapshots into a single snapshot with updates applied
50echo "Merging snapshots into one.."
51aptly snapshot merge -latest \
52 ${DEBIAN_RELEASE}-merged-`date +%Y%m%d%H` \
53 ${SNAPSHOTARRAY[@]}
54
55# Publish the latest merged snapshot
56set +e
57aptly publish list -raw | awk '{print $2}' | grep "^${DEBIAN_RELEASE}$"
58if [[ $? -eq 0 ]]; then
59 aptly publish switch \
60 -passphrase="${GPG_PASSWORD}" \
61 ${DEBIAN_RELEASE} ${DEBIAN_RELEASE}-merged-`date +%Y%m%d%H`
62else
63 aptly publish snapshot \
64 -passphrase="${GPG_PASSWORD}" \
65 -distribution=${DEBIAN_RELEASE} ${DEBIAN_RELEASE}-merged-`date +%Y%m%d%H`
66fi
67set -e
68
69# Export the GPG Public key
70if [[ ! -f /opt/aptly/public/aptly_repo_signing.key ]]; then
71 gpg --export --armor > /opt/aptly/public/aptly_repo_signing.key
72fi
73
74# Generate Aptly Graph
75aptly graph -output /opt/aptly/public/aptly_graph.png
diff --git a/assets/update_mirror_ubuntu.sh b/assets/update_mirror_ubuntu.sh
index 35787db..aa27bdf 100755
--- a/assets/update_mirror_ubuntu.sh
+++ b/assets/update_mirror_ubuntu.sh
@@ -16,65 +16,65 @@ if [ "$MODE" = "packages" ]; then
16 echo "File with a package list is not found" 16 echo "File with a package list is not found"
17 exit 1 17 exit 1
18 fi 18 fi
19 FILTER_OPTS=(-filter="$(cat /opt/packages/$PACKAGE_FILE | paste -sd \| -)" -filter-with-deps) 19 FILTER_VAL=$(paste -sd \| "/opt/packages/$PACKAGE_FILE")
20 FILTER_OPTS=("-filter=$FILTER_VAL" "-filter-with-deps")
20else 21else
21 FILTER_OPTS=() 22 FILTER_OPTS=()
22fi 23fi
23 24
25REPO_DATE=$(date +%Y%m%d%H)
26
24# Create repository mirrors if they don't exist 27# Create repository mirrors if they don't exist
25set +e
26for component in ${COMPONENTS}; do 28for component in ${COMPONENTS}; do
27 for repo in ${REPOS}; do 29 for repo in ${REPOS}; do
28 aptly mirror list -raw | grep "^${repo}-${component}$" 30 if ! aptly mirror list -raw | grep "^${repo}-${component}$"
29 if [[ $? -ne 0 ]]; then 31 then
30 echo "Creating mirror of ${repo}-${component} repository." 32 echo "Creating mirror of ${repo}-${component} repository."
31 aptly mirror create \ 33 aptly mirror create \
32 -architectures=amd64 "${FILTER_OPTS[@]}" ${repo}-${component} ${UPSTREAM_URL} ${repo} ${component} 34 -architectures=amd64 "${FILTER_OPTS[@]}" "${repo}-${component}" "${UPSTREAM_URL}" "${repo}" "${component}"
33 fi 35 fi
34 done 36 done
35done 37done
36set -e
37 38
38# Update all repository mirrors 39# Update all repository mirrors
39for component in ${COMPONENTS}; do 40for component in ${COMPONENTS}; do
40 for repo in ${REPOS}; do 41 for repo in ${REPOS}; do
41 echo "Updating ${repo}-${component} repository mirror.." 42 echo "Updating ${repo}-${component} repository mirror.."
42 aptly mirror update ${repo}-${component} 43 aptly mirror update "${repo}-${component}"
43 done 44 done
44done 45done
45 46
47SNAPSHOTARRAY=()
46# Create snapshots of updated repositories 48# Create snapshots of updated repositories
47for component in ${COMPONENTS}; do 49for component in ${COMPONENTS}; do
48 for repo in ${REPOS}; do 50 for repo in ${REPOS}; do
49 echo "Creating snapshot of ${repo}-${component} repository mirror.." 51 echo "Creating snapshot of ${repo}-${component} repository mirror.."
50 SNAPSHOTARRAY+="${repo}-${component}-`date +%Y%m%d%H` " 52 SNAPSHOTARRAY+=("${repo}-${component}-$REPO_DATE")
51 aptly snapshot create ${repo}-${component}-`date +%Y%m%d%H` from mirror ${repo}-${component} 53 aptly snapshot create "${repo}-${component}-$REPO_DATE" from mirror "${repo}-${component}"
52 done 54 done
53done 55done
54 56
55echo ${SNAPSHOTARRAY[@]} 57echo "${SNAPSHOTARRAY[@]}"
56 58
57# Merge snapshots into a single snapshot with updates applied 59# Merge snapshots into a single snapshot with updates applied
58echo "Merging snapshots into one.." 60echo "Merging snapshots into one.."
59aptly snapshot merge -latest \ 61aptly snapshot merge -latest \
60 ${UBUNTU_RELEASE}-merged-`date +%Y%m%d%H` \ 62 "${UBUNTU_RELEASE}-merged-$REPO_DATE" \
61 ${SNAPSHOTARRAY[@]} 63 "${SNAPSHOTARRAY[@]}"
62 64
63# Publish the latest merged snapshot 65# Publish the latest merged snapshot
64set +e 66if aptly publish list -raw | awk '{print $2}' | grep "^${UBUNTU_RELEASE}$"
65aptly publish list -raw | awk '{print $2}' | grep "^${UBUNTU_RELEASE}$" 67then
66if [[ $? -eq 0 ]]; then
67 aptly publish switch \ 68 aptly publish switch \
68 -batch=true \ 69 -batch=true \
69 -passphrase="${GPG_PASSWORD}" \ 70 -passphrase="${GPG_PASSWORD}" \
70 ${UBUNTU_RELEASE} ${UBUNTU_RELEASE}-merged-`date +%Y%m%d%H` 71 "${UBUNTU_RELEASE}" "${UBUNTU_RELEASE}-merged-$REPO_DATE"
71else 72else
72 aptly publish snapshot \ 73 aptly publish snapshot \
73 -batch=true \ 74 -batch=true \
74 -passphrase="${GPG_PASSWORD}" \ 75 -passphrase="${GPG_PASSWORD}" \
75 -distribution=${UBUNTU_RELEASE} ${UBUNTU_RELEASE}-merged-`date +%Y%m%d%H` 76 -distribution="${UBUNTU_RELEASE}" "${UBUNTU_RELEASE}-merged-$REPO_DATE"
76fi 77fi
77set -e
78 78
79# Export the GPG Public key 79# Export the GPG Public key
80if [[ ! -f /opt/aptly/public/aptly_repo_signing.key ]]; then 80if [[ ! -f /opt/aptly/public/aptly_repo_signing.key ]]; then