-
Notifications
You must be signed in to change notification settings - Fork 0
/
chroot-psd.sh
executable file
·86 lines (75 loc) · 2.13 KB
/
chroot-psd.sh
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
#!/bin/bash
for i in {45..40} {40..45} ; do echo -en "\e[38;5;${i}m##\e[0m" ; done ; echo
#echo -e "\e[92m==========================================="
echo -e "\e[92mWelcome to the Idiot Circumvention Program!"
echo ~~~ By Jaime Renee Wissner
echo It appears you\'ve damaged your system\'s drivers. This tool will chroot you into your installed system.
echo -e "This program is intended to be run on a live USB or a separate OS on the same system as your damaged system.\e[0m"
#echo -e "==========================================\e[0m"
for i in {45..40} {40..45} ; do echo -en "\e[38;5;${i}m##\e[0m" ; done ; echo
echo
if [[ "$EUID" -ne 0 ]]
then echo "This tool needs to run as root."
exit
fi
[[ $DEBUG == true ]] && set -x
lsblk
echo
echo I\'ve listed the detected storage devices above.
echo
read -p "What partition is your root mount (/)? " ROOTPART
if [[ -z $ROOTPART ]]; then
echo The root mount MUST be provided.
exit 1
else
if [[ ! -e /dev/$ROOTPART ]]; then
echo Device does not seem to exist. Is it in the list above?
exit 1
fi
fi
read -p "What partition is your home directory (/home)? " HOMEPART
if [[ -z $HOMEPART ]]; then
read -p "Are you sure you don't want to mount a home directory? " -n 1 NOHOME
if [[ $NOHOME == "y" ]]; then
HOMEPART="not being used today"
SKIP_HOME_PART=true
else
echo
echo I\'m not doing this recursively. Rerun the script and think carefully.
exit 1
fi
else
if [[ ! -e /dev/$HOMEPART ]]; then
echo Device does not seem to exist. Is it in the list above?
exit 1
fi
fi
echo
echo CONFIRMING! Your root mount is $ROOTPART, and your home mount is $HOMEPART?
read -p "Confirming root mount: $ROOTPART | home mount: $HOMEPART (y/N)" -n 1 -r CONFIRM
case "$CONFIRM" in
[yY])
CONFIRMED=true
echo Continuing...
;;
[nN])
echo Please rerun with the correct mount points.
exit 1
;;
* )
echo No input. Please rerun to continue.
exit 1
;;
esac
if [[ $CONFIRMED == true ]]; then
cd /
mount /dev/$ROOTPART /mnt
[[ $SKIP_HOME_PART != true ]] && mount /dev/$HOMEPART /mnt/home
cd /mnt
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/
chroot .
exit 0
fi
set +x