Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfixes for ubuntu offline installation in air-gap mode #613

Merged
merged 5 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG-0.4.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog 0.4

## [0.4.1] 2019-10-17

### Fixed

- [#613](https://github.com/epiphany-platform/epiphany/pull/613) - Hotfixes for Ubuntu offline installation in air-gap mode

## [0.4.0] 2019-10-11

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ download_image() {
else
local tmp_file=$(mktemp)
echo "Downloading image: $1"
echo "Skopeo command is: ./skopeo_linux --insecure-policy copy docker://{$image_name} docker-archive:${dst_image}:${repository}:${tag}"
echo "Skopeo command is: ./skopeo_linux --insecure-policy copy docker://${image_name} docker-archive:${dst_image}:${repository}:${tag}"
# use temporary file for downloading to be safe from sudden interruptions (network, ctrl+c)
./skopeo_linux --insecure-policy copy docker://${image_name} docker-archive:${tmp_file}:${repository}:${tag} && chmod 644 ${tmp_file} && mv ${tmp_file} ${dst_image}
fi
Expand Down Expand Up @@ -74,8 +74,5 @@ download_file() {

# --no-use-server-timestamps - we don't use --timestamping and we need to expire files somehow
# --continue - don't download the same file multiple times, gracefully skip if file is fully downloaded
wget --no-use-server-timestamps --continue --show-progress --directory-prefix="${dest_dir}" "${file_url}"

#wget --no-verbose --directory-prefix="$dest_dir" "$file_url" ||
#exit_with_error "Command failed: wget --no-verbose --directory-prefix=\"$dest_dir\" \"$file_url\""
wget --no-use-server-timestamps --continue --show-progress --prefer-family=IPv4 --directory-prefix="${dest_dir}" "${file_url}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,38 @@

EPI_REPO_SERVER_PATH=$1 # /var/www/html/epirepo is the default
IS_OFFLINE_MODE=$2
script_path="$( cd "$(dirname "$0")" ; pwd -P )"

if $IS_OFFLINE_MODE = true; then
# bootstrap apache and dpkg-dev installation in air-gap mode
if [[ -f /etc/apt/sources.list ]]; then
echo "disabling default repositories..."
mv /etc/apt/sources.list /etc/apt/sources.list.bak
fi
if ! dpkg -l | grep -q libdpkg-perl; then
echo libdpkg-perl not found, installing...
dpkg -i ${EPI_REPO_SERVER_PATH}/packages/libdpkg-perl*.deb
dpkg -i "${EPI_REPO_SERVER_PATH}"/packages/libdpkg-perl*.deb
fi
cd ${EPI_REPO_SERVER_PATH}/packages && /tmp/epi-repository-setup-scripts/dpkg-scanpackages -m . | gzip -9c > Packages.gz && cd -
echo "generating repository metadata..."
cd "${EPI_REPO_SERVER_PATH}"/packages && /tmp/epi-repository-setup-scripts/dpkg-scanpackages -m . | gzip -9c > Packages.gz && cd "${script_path}"
echo "deb [trusted=yes] file:${EPI_REPO_SERVER_PATH}/packages ./" > /etc/apt/sources.list.d/epilocal.list
apt update --assume-no # workaround for botched docker repository https://github.com/docker/for-linux/issues/812
#apt update --assume-no # workaround for botched docker repository https://github.com/docker/for-linux/issues/812
echo "updating apt and installing apache..."
apt -y update
apt -y install apache2 dpkg-dev
echo "removing temporary repo definition: /etc/apt/sources.list.d/epilocal.list..."
rm -f /etc/apt/sources.list.d/epilocal.list
rm -f ${EPI_REPO_SERVER_PATH}/packages/Packages.gz
apt update --assume-no
#rm -f ${EPI_REPO_SERVER_PATH}/packages/Packages.gz
echo "updating apt..."
apt -y update
else
# for online mode just install apache
apt -y install apache2 dpkg-dev

# -m is important because it allow same packages with different versions
# 'cd' is needed here becuase 'dpkg-scanpackages' prepends path to "Filename" field in Packages.gz
# otherwise it would break package URL for apt
cd /var/www/html/epirepo/packages && dpkg-scanpackages -m . | gzip -9c > Packages.gz && cd "${script_path}"
fi

systemctl start apache2

# -m is important because it allow same packages with different versions
# 'cd' is needed here becuase 'dpkg-scanpackages' prepends path to "Filename" field in Packages.gz, otherwise it would break package URL for apt
cd /var/www/html/epirepo/packages && dpkg-scanpackages -m . | gzip -9c > Packages.gz
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
---
- name: Create epirepo repository
shell: >-
/tmp/epi-repository-setup-scripts/create-repository.sh /var/www/html/epirepo {{ offline_mode | lower }} |&
set -o pipefail && /tmp/epi-repository-setup-scripts/create-repository.sh /var/www/html/epirepo {{ offline_mode | lower }} |&
tee /tmp/epi-repository-setup-scripts/create-repository.log
args:
executable: /bin/bash
when:
- not custom_repository_url
- inventory_hostname in groups['repository']

- name: Ensure apache is running
service:
name: apache2
state: started
when:
- not custom_repository_url
- inventory_hostname in groups['repository']

- name: Disable system repositories and set up epirepo
block:
- name: Create list of enabled repositories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
name: httpd
state: started
when:
- ansible_os_family == "RedHat"
- not custom_repository_url
- inventory_hostname in groups['repository']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
loop:
- /tmp/epi-download-requirements
- /tmp/epi-repository-setup-scripts
- /var/tmp/enabled-system-repos.txt
- /var/tmp/enabled-system-repos.txt
- /var/tmp/enabled-system-repos.tar