#!/usr/bin/env bash # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -eE set -o nounset set -o pipefail echo "Validating all symlinks are valid" if [[ "${IGNORE_DANGLING_SYMLINKS:-false}" = "true" ]]; then exit 0 fi cd /newroot EXPECTED_DANGLING_LINKS=("/var/lock" "/etc/mtab") GREPS="" for expected in "${EXPECTED_DANGLING_LINKS[@]}"; do GREPS+="-e $expected " done DANGLING="$(symlinks -C -r . | grep "dangling" | grep -v $GREPS || true)" if [ ! -z "$(echo $DANGLING | xargs)" ]; then echo "$DANGLING" exit 1 fi