-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrootdev
More file actions
executable file
·26 lines (23 loc) · 968 Bytes
/
rootdev
File metadata and controls
executable file
·26 lines (23 loc) · 968 Bytes
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
#!/bin/bash
# reMarkable 2 will not recognize root when using the stock version of rootdev, so we do this little hack.
# From gentoo wiki
cmdline() {
local value
value=" $(cat /proc/cmdline) "
value="${value##* ${1}=}"
value="${value%% *}"
[ "${value}" != "" ] && echo "${value}"
}
function rootdev_new() {
probed_path=$(echo -ne "$@ " | sed "s~-[cdis][cdis]*\s\s*~~g" | sed "s~--\(block\|dev\) [[:alnum:]/][[:alnum:]/]*\s\s*~~g" | sed "s~--\(minor\|major\) [0-9][0-9]*\s\s*~~g" | sed "s~\s*$~~g" | sed "s~\s*$~~g" | sed "s~^\s*~~g")
if [ ! -e ${probed_path} ] || [[ ${probed_path} =~ ^\ +$ ]] || [[ "${probed_path}" == "" ]] ; then
probed_path="/"
fi
probed_path=$(df --output=source ${probed_path} | tail -n1)
if [[ ${probed_path} == "none" ]]; then
echo -e "$(cmdline root)"
else
echo ${probed_path}
fi
}
rootdev.old "$@" 1>/dev/null 2>/dev/null && rootdev.old "$@" || rootdev_new "$@"