File: install.sh

package info (click to toggle)
arename 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,112 kB
  • sloc: perl: 640; sh: 585; makefile: 147
file content (35 lines) | stat: -rwxr-xr-x 678 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh

MODE="$1"
SRC="$2"
DST="$3"
WIDTH="${4:-0}"

if [ -z "${SRC}" ] || [ -z "${DST}" ] ; then
    printf 'usage: install.sh <x|n> <file> <dest-dir> <srcwidth>\n'
    exit 1
fi

umask 0022

if [ "${WIDTH}" -gt 0 ] ; then
    printf 'Installing %'"${WIDTH}"'s to %s\n' "${SRC}" "${DST}"
else
    printf 'Installing %'"${WIDTH}"'s to %s\n' "${SRC}" "${DST}"
fi

mkdir -p "${DST}"                   || exit 1
cp "${SRC}" "${DST}"                || exit 1
case "${MODE}" in
n)
    chmod 0644 "${DST}/${SRC##*/}"  || exit 1
    ;;
x)
    chmod 0755 "${DST}/${SRC##*/}"  || exit 1
    ;;
*)
    printf 'Unknown mode '\''%s'\'', ABORT.\n' "${MODE}"
    exit 1
    ;;
esac
exit 0