-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathinstall.sh
121 lines (103 loc) · 3.54 KB
/
install.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
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
118
119
120
121
# PSHMode logs
LOG_FILE=".PSHMode-install.log"
echo "" >$LOG_FILE
# Get the platform.
PLATFORM=$(python3 -c "import sys, os, platform;print('win' if sys.platform in ('win32', 'cygwin') else 'macosx' if sys.platform == 'darwin' else 'termux' if os.environ.get('PREFIX') != None else 'ish shell' if platform.release().endswith('ish') else 'linux' if sys.platform.startswith('linux') or sys.platform.startswith('freebsd') else 'unknown')")
# Remove old version from the tool.
python3 -c 'import subprocess;subprocess.run(["bash", "-i", "-c", "HackerMode delete"], stdout=subprocess.PIPE, text=True, input="y")' &>/dev/null
rm -rif HackerMode ~/.HackerMode ~/../usr/bin/HackerMode &>/dev/null
rm -f HackerModeInstall &>/dev/null
rm -rif PSHMode ~/.PSHMode ~/../usr/bin/PSHMode &>/dev/null
rm -f PSHMode.install &>/dev/null
# To install before setup the tool.
PSHMODE_PACKAGES=(
wget
git
unzip
zip
)
# Download PSHMode and move it to home.
function download_PSHMode() {
cd "$HOME"
rm -f main.zip
wget https://github.com/Arab-developers/PSHMode/archive/refs/heads/main.zip &>>$LOG_FILE
unzip main.zip &>>$LOG_FILE
rm -f main.zip
mv -f PSHMode-main .PSHMode
}
if [[ $PLATFORM != "unknown" ]]; then
echo -e "Start installing for ( \033[1;32m$PLATFORM\033[0m )"
fi
# Linux installation...
if [[ "$PLATFORM" == "linux" ]]; then
# Install packages...
sudo apt --fix-broken install
sudo apt update -y
sudo apt install python3 -y
sudo apt install python3-pip -y
for PKG in ${PSHMODE_PACKAGES[*]}; do
sudo apt install "$PKG" -y
done
# Download the tool.
download_PSHMode
sudo python3 -B .PSHMode add_shortcut
python3 -B .PSHMode install
# Termux installation...
elif [[ "$PLATFORM" == "termux" ]]; then
# Install packages...
pkg update -y
pkg install python -y
for PKG in ${PSHMODE_PACKAGES[*]}; do
pkg install "$PKG" -y
done
pkg install zsh -y
# Get sdcard permission.
ls /sdcard &>>$LOG_FILE || termux-setup-storage
# Download the tool.
download_PSHMode
python3 -B .PSHMode add_shortcut
mkdir /sdcard/PSHMode &>>$LOG_FILE
# Add the font
if ! cmp --silent -- ".PSHMode/share/fonts/DejaVu.ttf" "~/.termux/font.ttf"; then
cp .PSHMode/share/fonts/DejaVu.ttf ~/.termux/font.ttf
termux-reload-settings
fi
# Start the installation
python3 -B .PSHMode install
elif [[ "$PLATFORM" == "ish shell" ]]; then
# Install packages...
apk fix
apk update
apk add python3
apk add musl-dev
apk add py3-pip
for PKG in ${PSHMODE_PACKAGES[*]}; do
apk add "$PKG"
done
# Add zshrc file.
if ! [[ -f ~/.zshrc ]]; then
touch ~/.zshrc
echo "PS1='%m:%~# '" >>~/.zshrc
fi
# Add include files to the system.
PY_VERSION_3_ITEMS=$(python3 -c 'import sys;print(sys.version.split(" ")[0])')
PY_VERSION=$(python3 -c 'import sys;print(sys.version.split(" ")[0].rsplit(".", 1)[0])')
if ! [[ -f /usr/include/python$PY_VERSION/Python.h ]]; then
wget https://www.python.org/ftp/python/$PY_VERSION_3_ITEMS/Python-$PY_VERSION_3_ITEMS.tar.xz
tar -xvf Python-$PY_VERSION_3_ITEMS.tar.xz Python-$PY_VERSION_3_ITEMS/Include
rm -f Python-$PY_VERSION_3_ITEMS.tar.xz
mv Python-$PY_VERSION_3_ITEMS/Include/* /usr/include/python$PY_VERSION/
rm -rif Python-$PY_VERSION_3_ITEMS
fi
# Download the tool.
download_PSHMode
python3 -B .PSHMode add_shortcut
python3 -B .PSHMode install
else
echo "# No support for '$PLATFORM'!"
fi
# Remove variables from the global namespace.
unset PLATFORM PSHMODE_PACKAGES LOG_FILE
unset -f download_PSHMode
# Add PSHMode command line.
source "$HOME"/.PSHMode/PSHMode.shortcut