aboutsummaryrefslogtreecommitdiff
path: root/board/common.sh
blob: 04f0cbc72c62884bdc9a4f3747adbecaf28afd90 (plain)
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
create_missing_dir() {
  echo "creating directory ${TARGET_DIR}/$1"
  test -d "${TARGET_DIR}/$1" || mkdir -p "${TARGET_DIR}/$1"
}

remove_text() {
  echo sed --in-place "s/$2//" $1
  sed --in-place "s/$2//" $1
}

add_tmpfs() {
  create_missing_dir "$1"
  if ! grep -q "$1" "${TARGET_DIR}/etc/fstab"; then
      cat << __EOF__ >> "${TARGET_DIR}/etc/fstab"
tmpfs $1 tmpfs rw 0 0
__EOF__
  fi
}

# Enable a systemd service
enable_service() {
  if [ -e "$BR2_EXTERNAL_PIAUDIO_PATH/local/services/$1" ]; then
    cp "$BR2_EXTERNAL_PIAUDIO_PATH/local/services/$1" "${TARGET_DIR}/etc/systemd/system/$1"
  else
    echo "WARN: local/services/$1 does not exists"
  fi
  ln -sf /etc/systemd/system/$1 "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/$1"
}