-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchmod
More file actions
44 lines (35 loc) · 1.25 KB
/
chmod
File metadata and controls
44 lines (35 loc) · 1.25 KB
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
36
37
38
39
40
41
42
43
#!/bin/bash
# chmod a file on the image
# default options
RPI_CHMOD_PERM="${RPI_CHMOD_PERM:=}"
RPI_CHMOD_PATH="${RPI_CHMOD_PATH:=}"
RPI_CHMOD_RECURSIVE="${RPI_CHMOD_RECURSIVE:=false}"
function rpi_chmod_prerun() {
[[ -n "${RPI_CHMOD_PERM}" ]] || error "RPI_CHMOD_PERM check"
[[ -e "${RPI_CHMOD_PATH}" ]] || error "RPI_CHMOD_PATH check"
}
function rpi_chmod_run() {
rpi_chmod_pi "${RPI_CHMOD_PERM}" "${RPI_CHMOD_PATH}" "${RPI_CHMOD_RECURSIVE}" || error "rpi_chmod_pi"
}
function rpi_chmod_description() {
echo "chmod a file on the image"
}
function rpi_chmod_help_params() {
help_param "RPI_CHMOD_PERM" "permissions"
help_param "RPI_CHMOD_PATH" "path to chmod target"
help_param "RPI_CHMOD_RECURSIVE" "chmod (only files) recursively if true"
}
# ---------------------------------------------------------------------
# chmod wrapper
function rpi_chmod_pi() {
local permissions="$1"
local path="$2"
local recursive="$3"
if [[ -z "${permissions}" ]] && [[ -z "${path}" ]] ; then error "missing argument" ; fi
# directory ?
if [[ "${recursive}" == "true" ]] ; then
sudo find "${RPI_ROOT}/${path}" -type f -exec chmod "${permissions}" {} \;
else
sudo chmod "${permissions}" "${RPI_ROOT}/${path}"
fi
}