-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEdit Root Volume
executable file
·117 lines (94 loc) · 4.01 KB
/
Edit Root Volume
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# Run in recovery `csrutil disable`
# Run in recovery `csrutil authenticated-root disable`
# On apple intel `sudo bless --folder instead of --mount`
mtn_path=~/livemount
snapshot_disk=$(mount | grep sealed | grep 'on / ' | awk '{print $1}')
parent_disk=$(echo $snapshot_disk | sed 's/s[0-9]*$//')
unmount_disk(){
echo -e "$sexc - Unmounting disk..."
sudo umount $mtn_path/ # Unmounts disk
success=$?
if [[ "$success" = "0" ]]; then # Remove mouting point if unmount sucessfull
echo -e "$sexc - Removing dir $mtn_path/..."
rm -rf $mtn_path/
else
echo -e "$swrn - An Error Occured: $mtn_path wasn't unmounted nor removed."
echo -e "$swrn - List of processes on $mtn_path/ :"
lsof $parent_disk
echo -e "$sqes - Do you want to try kill all disk related processes and retry? $syon"
echo -ne "$spmt"; read var; echo -ne "\033[0m"
if [[ "$var" == "y" ]]; then
echo -e "$sexc - Trying to kill all related processes..."
lsof $parent_disk | awk 'NR>1 {print $2}' | xargs kill -9
unmount_disk
fi
fi
}
mount_disk(){
mkdir $mtn_path # Create Mounting point
echo -e "$smak - Attempting to mount \033[38;5;4;48;5;0;1m$parent_disk\033[0m \033[38;5;6mto \033[38;5;4;48;5;0;1m$mtn_path\033[0m."
sudo mount -o -nobrowse -t apfs $parent_disk $mtn_path/ # Mounts root volume to mount point
#give_ownership # Really extremely bad idea...
}
#==== Styling ====
spmt='\033[38;5;5;1m> \033[0m\033[48;5;0m' # >_
sqes='\033[48;5;0;38;5;8m[\033[38;5;4m?\033[38;5;8m]\033[0m' # [?]
scac='\033[48;5;0;38;5;8m[\033[38;5;1mx\033[38;5;8m]\033[0m' # [x]
sexc='\033[48;5;0;38;5;8m[\033[38;5;2mo\033[38;5;8m]\033[0m' # [o]
smak='\033[48;5;0;38;5;8m[\033[38;5;5m+\033[38;5;8m]\033[0m' # [+]
swrn='\033[48;5;0;38;5;8m[\033[38;5;3m!\033[38;5;8m]\033[0m' # [!]
syon='(\033[38;5;2;1my\033[38;5;0m/\033[38;5;1;1mn\033[0m)' # (y/n)
brkline() {
col=$(( $(tput cols) - 1 ))
for i in $(seq 0 $col); do
if [[ $i == 0 ]]; then
echo -ne "$1\033[0m"
elif [[ $i == $col ]]; then
echo -ne "$3\033[0m"
else
echo -ne "$2\033[0m"
fi
done
}
#give_ownership(){
# echo -e "$sqes - Do you want to open a separate Terminal window to give $USER the ownership of $mtn_path ? (y/n) : "
# read var
# if [[ "$var" == "y" ]]; then
# echo "Giving ownership of $mtn_path to $USER..."
# osascript -e "tell application \"Terminal\" to do script \"clear; echo Giving ownership of $mtn_path to $USER; sudo chown -R $USER $mtn_path; exit \""
# fi
#}
brkline '\033[38;5;4m>' '\033[38;5;4m-' '\033[38;5;4m<'
echo -e "\033[38;5;1m\033[48;5;0;1mCAUTION /!\\ \033[0m: \033[38;5;3;1mThis program is experimental run it at your own risks."
echo -e "Errors in the programm or misuse could entirely detstroy your MacOS instance\033[0m"
brkline '\033[38;5;4m>' '\033[38;5;4m-' '\033[38;5;4m<'
echo -e "$sqes - Do you wish to proceed ? $syon"
echo -ne "$spmt"; read var; echo -ne "\033[0m"
if [[ "$var" == "y" ]]; then
mount_disk
open $mtn_path/
echo -e "$sqes - Update changes ? $syon"
echo -ne "$spmt"; read var; echo -ne "\033[0m"
if [[ "$var" == "y" ]]; then
echo -e "$smak - Snapshot \033[38;5;4;48;5;0;1m$snapshot_disk\033[0m updated \033[38;5;6mfrom \033[38;5;4;48;5;0;1m$mtn_path/\033[0m."
sudo bless --mount $mtn_path/System/Library/CoreServices --bootefi --create-snapshot
echo -e "$sqes - Reboot to apply changes? $syon"
echo -ne "$spmt"; read var; echo -ne "\033[0m"
if [[ "$var" == "y" ]]; then
unmount_disk
echo -e "$sexc - Rebooting..."
sudo reboot
elif [[ "$var" == "n" ]]; then
echo -e "$scac - Rebooting aborted."
unmount_disk
fi
elif [[ "$var" == "n" ]]; then
echo -e "$scac - Not updated."
unmount_disk
else
exit
fi
fi
echo -ne "$sexc - Task completed, press \033[38;5;5;1menter\033[0m to \033[38;5;1;1mquit\033[0m."
read t