-
Notifications
You must be signed in to change notification settings - Fork 15
/
qone_setup.sh
78 lines (70 loc) · 2.35 KB
/
qone_setup.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
#!/bin/bash
# Check if wget is installed, and install it if necessary
if ! command -v wget &> /dev/null; then
echo "⌛️ wget is not installed. Installing wget..."
sleep 1
sudo apt update
sudo apt install wget -y
if [ $? -ne 0 ]; then
echo "❌ Error: Failed to install wget."
exit 1
fi
fi
# Remove existing qone.sh if it exists
if [ -e ~/qone.sh ]; then
rm ~/qone.sh
if [ $? -ne 0 ]; then
echo "❌ Error: Failed to remove qone.sh"
fi
fi
# Download the qone.sh script
wget -O ~/qone.sh https://github.com/lamat1111/QuilibriumScripts/raw/main/qone.sh
if [ $? -ne 0 ]; then
echo "❌ Error: Failed to download qone.sh script."
exit 1
fi
# Make qone.sh executable
chmod +x ~/qone.sh
if [ $? -ne 0 ]; then
echo "❌ Error: Failed to make qone.sh executable. You will have to do this manually."
sleep 1
# Continue execution even if chmod fails
fi
# Check if the qone.sh setup section is already present in .bashrc
if grep -Fxq "# === qone.sh setup ===" ~/.bashrc; then
echo "⚠️ The qone.sh setup section is already present in .bashrc."
echo "Skipping the setup steps..."
else
# Check if there's already a section for another script in .bashrc
if grep -q "# === [^=]*setup ===" ~/.bashrc; then
echo "⚠️ Warning: Another script seems to be already set up to run on login."
echo "To avoid conflicts, qone.sh will not be executed on login, but aliases will be set up."
sleep 1
# Define the section to add in .bashrc without the execution line
bashrc_section=$(cat << 'EOF'
# === qone.sh setup ===
# this allows you to call the qone menu with "q1" or "qone"
alias q1='~/qone.sh'
alias qone='~/qone.sh'
# === end qone.sh setup ===
EOF
)
else
# Define the section to add in .bashrc with the execution line
bashrc_section=$(cat << 'EOF'
# === qone.sh setup ===
# this allows you to call the qone menu with "q1" or "qone"
alias q1='~/qone.sh'
alias qone='~/qone.sh'
# === end qone.sh setup ===
EOF
)
fi
# Add the section to the end of .bashrc if not already present
echo "$bashrc_section" >> ~/.bashrc
if [ $? -ne 0 ]; then
echo "❌ Error: Failed to add section to .bashrc. No worries, this is optional."
sleep 1
# Continue execution even if adding section to .bashrc fails
fi
fi