Skip to content
This repository was archived by the owner on May 17, 2019. It is now read-only.

Commit d1255ca

Browse files
author
NerdOfCode
committed
Improving Run Script
1 parent a061c22 commit d1255ca

3 files changed

Lines changed: 44 additions & 36 deletions

File tree

Src/global_bash_var

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ DEFAULT_LOCATION="/etc/Restricted-Shell/"
99
#Define last-updated date
1010
LAST_UPDATED="10/28/18"
1111

12+
#Check if any updates via git everytime "run.sh" is ran
13+
#Default: Off
14+
updates=0
15+
1216
#Define colors for color-coating output
1317
RED_TEXT='\033[0;31m'
1418
RESET='\033[0m'

reinstall.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ root_check(){
1818

1919
if [[ "$(whoami)" != "root" ]]
2020
then
21-
echo "This script will most likely need root."
21+
echo "Error: Not Root!"
2222
echo "Pass '--no-root' if you're willing to risk it."
2323
exit -1
2424
fi

run.sh

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,51 @@
2626
#Source the global_bash_var file
2727
source Src/global_bash_var
2828

29-
#Change to 0 to turn auto updates off
30-
updates=0
31-
29+
#If file exists, don't prompt user for start-configuration
3230
config=".config"
3331

3432
#Change to 1 if you don't want to recompile if built
3533
dont_compile=0
3634

37-
##Where users are stored
38-
##UNUSED AS OF 7/10/18
39-
user_db="Logs/users.db"
40-
4135
##FOR COLOR COATING
4236
RED='\033[0;41m'
4337
YELLOW='\e[0;33m'
4438

4539
RESET='\033[0;37m'
4640

47-
4841
if [[ "$updates" == "1" ]]
4942
then
50-
echo "Updating repository..."
43+
echo "Updating repository..."
5144
git pull origin master
5245
fi
5346

5447
#Shortcut to make sure all shell scripts are in fact executable
5548
chmod +x Bin/*
5649

50+
help(){
51+
#If --help flag is thrown
52+
echo "Below are the available options:"
53+
echo " --help -> Display this help menu"
54+
echo " --reinstall -> Display reinstallation instructions"
55+
echo " --update -> Update the R-Shell via Git"
56+
57+
exit 0
58+
}
59+
60+
reinstall(){
61+
#If --reinstall flag is thrown
62+
echo "Please run: "
63+
echo " bash reinstall.sh"
64+
exit 0
65+
}
66+
67+
check_updates(){
68+
#If --update flag is thrown
69+
echo "Attempting to update..."
70+
git pull origin master
71+
exit 0
72+
}
73+
5774
check_commands(){
5875

5976
exit_status=0
@@ -127,37 +144,26 @@ sign_in(){
127144
fi
128145

129146
}
130-
create_admin_acc(){
131147

132-
sqlite3 $user_db "CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT NOT NULL, password TEXT NOT NULL);"
148+
#Run through args
133149

134-
status=$(sqlite3 $user_db "SELECT id FROM users WHERE id=1;")
135-
admin_count=$(sqlite3 $user_db "SELECT id FROM users;")
136-
137-
#echo "Local Admins: ${admin_count: -1}"
138-
139-
if [ "$status" == "1" ]
150+
for arg in "$@"
151+
do
152+
if [[ "$arg" == "--help" ]]
140153
then
141-
echo "You will need to be signed in by an exisiting administrator! "
142-
sign_in
154+
help
143155
fi
144156

145-
if [[ $add_admin != 0 ]]
146-
then
147-
printf "${RED}One More Thing! It is Time to setup the Admin account!\n"
148-
printf "Enter the following information!${RESET}\n"
149-
150-
read -p "Enter Username: " username
151-
read -p "Enter Password: " password
157+
if [[ "$arg" == "--reinstall" ]]
158+
then
159+
reinstall
160+
fi
152161

153-
password="$(echo \"$password\" | sha512sum | awk -F ' ' '{print $1}' )"
154-
echo $password
155-
sqlite3 $user_db "INSERT INTO users(username,password) VALUES(\"$username\", \"$password\");"
162+
if [[ "$arg" == "--update" ]]
163+
then
164+
check_updates
156165
fi
157-
158-
}
159-
160-
clear
166+
done
161167

162168
check_commands
163169

@@ -267,8 +273,6 @@ fi
267273

268274
clear
269275

270-
#create_admin_acc
271-
272276
check_exec
273277

274278
if [[ $dont_compile -eq 0 ]]

0 commit comments

Comments
 (0)