91c30f6ab2
Also modified dib-run-parts to apply a more workable solution for filtering out unwanted files such as editor backups and VCS. The script is installed in its own element, depended on by the OS specific ubuntu element. This is because the ubuntu element (and later other OS's) are responsible for populating the root filesystem. If we try to install this in base, the root filesystem will look to be populated already and we will skip automatically choosing ubuntu. Change-Id: I017646748c1a8360299106289b57d976d45875a8
55 lines
1.4 KiB
Bash
55 lines
1.4 KiB
Bash
#!/bin/bash
|
|
# Inspired by Debian and RedHat run-parts but portable and specific to di-b.
|
|
#
|
|
# Copyright 2012 Hewlett-Packard Development Company, L.P.
|
|
# 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.
|
|
|
|
allowed_regex=${RUN_PARTS_REGEX:-"^[0-9A-Za-z_-]+$"}
|
|
|
|
set -ue
|
|
|
|
name=$(basename $0)
|
|
|
|
usage() {
|
|
echo "usage: $name scripts_directory" >&2
|
|
exit 1
|
|
}
|
|
|
|
output () {
|
|
echo $name $(date) $* >&2
|
|
}
|
|
|
|
if [ $# -lt 1 ] ; then
|
|
usage
|
|
fi
|
|
|
|
target_dir=$1
|
|
|
|
if ! [ -d $target_dir ] ; then
|
|
output $target_dir must exist and be a directory
|
|
usage
|
|
fi
|
|
|
|
# We specifically only want to sort *by the numbers*.
|
|
# Lexical sorting is not guaranteed, and identical numbers may be
|
|
# parallelized later
|
|
targets=$(find $target_dir -type f -executable -printf '%f\n' | grep -E "$allowed_regex" | LANG=C sort -n)
|
|
|
|
for target in $targets ; do
|
|
output "Running $target_dir/$target"
|
|
$target_dir/$target
|
|
output "$target completed"
|
|
done
|