Skip to content

Commit ec90a35

Browse files
committed
add a script edit-pi-config to edit config.txt in efi partition
1 parent f6d7863 commit ec90a35

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2020 The Fyde Innovations. All rights reserved.
2+
# Distributed under the license specified in the root directory of this project.
3+
4+
EAPI="5"
5+
6+
DESCRIPTION="A simple script to edit config.txt in efi partition"
7+
HOMEPAGE="https://fydeos.com"
8+
9+
LICENSE="BSD-Google"
10+
SLOT="0"
11+
KEYWORDS="*"
12+
IUSE=""
13+
14+
RDEPEND=""
15+
16+
DEPEND="${RDEPEND}"
17+
S=${WORKDIR}
18+
19+
src_install() {
20+
exeinto /usr/share/edit-pi-config
21+
doexe ${FILESDIR}/edit-pi-config
22+
dosym /usr/share/edit-pi-config/edit-pi-config /usr/sbin/edit-pi-config
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
EDITOR="/usr/local/bin/nano"
6+
EDITOR_ALT="/bin/nano"
7+
CONFIG_FILE="config.txt"
8+
EFI_TYPE="c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
9+
10+
PARTITION=""
11+
TARGET_PATH=""
12+
13+
error() {
14+
echo "error: $*" >&2
15+
}
16+
17+
die() {
18+
error "$*"
19+
exit 1
20+
}
21+
22+
check_user() {
23+
if [[ $EUID -ne 0 ]]; then
24+
die "Please run this script as root or prepend sudo, abort."
25+
fi
26+
}
27+
28+
check_editor() {
29+
if [[ ! -x $EDITOR ]]; then
30+
EDITOR="$EDITOR_ALT"
31+
fi
32+
if [[ ! -x $EDITOR ]]; then
33+
die "editor nano not found, abort."
34+
fi
35+
}
36+
37+
find_root_dev() {
38+
local dev=""
39+
dev=$(rootdev -d)
40+
if [[ "$dev" = "/dev/"* ]]; then
41+
dev="${dev:5}"
42+
fi
43+
echo "$dev"
44+
}
45+
46+
find_efi_part() {
47+
local ROOT_DEV=""
48+
local PARTITION_NAME=""
49+
ROOT_DEV=$(find_root_dev)
50+
if [[ -z $ROOT_DEV ]]; then
51+
die "rootdev not found, abort."
52+
fi
53+
PARTITION_NAME=$(lsblk -l -o NAME,PARTTYPE | grep "$EFI_TYPE" | awk '$1 ~ /'"$ROOT_DEV"'.*/ {print $1}')
54+
if [[ -z $PARTITION_NAME ]]; then
55+
die "no EFI partition found, abort."
56+
fi
57+
58+
PARTITION="/dev/$PARTITION_NAME"
59+
TARGET_PATH="/tmp/$PARTITION_NAME"
60+
}
61+
62+
main() {
63+
check_editor
64+
check_user
65+
66+
find_efi_part
67+
68+
mkdir -p "$TARGET_PATH"
69+
umount "$PARTITION" || true
70+
mount "$PARTITION" "$TARGET_PATH" || die "mount failed"
71+
72+
$EDITOR "${TARGET_PATH}/${CONFIG_FILE}"
73+
74+
umount "$TARGET_PATH"
75+
}
76+
77+
main
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fyde-packages-0.0.1.ebuild

project-cros-pi/virtual/fyde-packages/fyde-packages-0.0.1.ebuild

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ RDEPEND="
1818
widevine? ( chromeos-base/libwidevine )
1919
kiosk_demo? ( chromeos-base/fyde-kiosk-demo )
2020
fyde_extension? ( chromeos-base/fyde-shell-daemon-bin )
21+
chromeos-base/edit-pi-config
2122
"
2223

2324
DEPEND="${RDEPEND}"

0 commit comments

Comments
 (0)