Skip to content
Snippets Groups Projects
Unverified Commit 3875b0dc authored by HUC Stéphane's avatar HUC Stéphane
Browse files

fix: replace grep by expansion

parent fda0f762
No related branches found
No related tags found
No related merge requests found
......@@ -2,51 +2,41 @@
#set -x
set -e -u
### 2020/05/19 15:15
### 2020/05/25 18:35
# chroot_deps: cmp needed binaries between sys and chroot web.
# v6.7: libc.so.96.0
# v6.6: libc.so.95.1
##
# find /var/www/usr/ -type f | while read ligne ; do cmp ${ligne##/var/www} ${ligne} || cp ${ligne##/var/www} ${ligne} ; done
#
# v6.7: libc.so.96.0
# v6.6: libc.so.95.1
###
chroot="/var/www"
bins='cat date sh sha256'
usrbins='awk basename grep logger stat'
usrbins='basename logger stat'
libs='libc.so.96.0'
libexecs='ld.so'
check_file() {
local dir="$1"
local file="${chroot}${dir}/${bin}"
local mssg=''
local status=0
if [ ! -f "${file}" ]; then
mssg="$0: file '$file' not exists, do a copy into chroot: '$chroot'!"
logger "${mssg}"
printf '%s\n' "${mssg}"
logger "$0: file '$file' not exists, do a copy into chroot: '$chroot'!"
_cp "${dir}/${bin}"
else
if ! cmp -s "${dir}/${bin}" "${file}"; then _cp "${dir}/${bin}"; fi
if cmp -s "${dir}/${bin}" "${file}"; then _cp "${dir}/${bin}"; fi
fi
}
_cp() {
local src="$1"
local dest="${chroot}${src}"
local mssg=''
if printf '%s' "${src}" | grep -q bin; then mode=555; fi
if printf '%s' "${src}" | grep -q lib; then mode=444; fi
if [ -n "${src:+bin}" ]; then mode=555; fi
if [ -n "${src:+lib}" ]; then mode=444; fi
if install -o root -g bin -m "${mode}" "${src}" "${dest}"; then
mssg="$0: copied dependency '$src' to '$dest'!"
logger "${mssg}"
printf '%s\n' "${mssg}"
logger "$0: copied dependency '$src' to '$dest'!"
else
mssg="$0: Can not copy dependency '$src' to '$chroot'!"
logger "${mssg}"
printf '%s\n' "${mssg}"
logger "$0: Can not copy dependency '$src' to '$chroot'!"
fi
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment