This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·52 lines (49 loc) · 1.59 KB
/
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
#!/bin/bash
#
# Author: Sagar Biswas (sagar040)
#
# https://github.com/sagar040/chatGPT
#
# Setup file
dir_api="./api"
api_conf="$dir_api/conf.py"
date_path=$(which date)
DAT=$($date_path)
if [ -f $api_conf ]; then
echo -e "\033[33m(!)\033[0m '$api_conf' already exists.\n"
echo -n "Do you want to remove it ? (y/n) : "
read purge;
if [ $purge = 'y' ]; then
backup=$(cat "$dir_api/.backup")
rm -rf $dir_api
echo -e "\n-- $dir_api removed"
mkdir $dir_api
echo "-- backing up old api key"
echo -e "$backup\n" > "$dir_api/.backup"
echo "-- old api keys are stored at '$dir_api/.backup'"
echo -e "-- creating $api_conf\n"
touch $api_conf
echo -e -n "\033[35mEnter your api key:\033[33m "
read key;
echo -e -n "\033[0m"
echo -n "IyBhcGkgY29uZmlndXJhdGlvbgojIGFkZCB5b3VyIGFwaSBrZXkgaGVyZQojIGtleSA9ICcnCg==" | base64 -d > $api_conf
echo "key = '$key'" >> $api_conf
echo -e "$DAT\n" >> "$dir_api/.backup"
echo -e "$key\n" >> "$dir_api/.backup"
echo -e "\033[32mdone..\033[0m"
else
echo -e "\nyou can change your api key at '$api_conf'"
exit
fi
else
mkdir $dir_api
touch $api_conf
echo -e -n "\033[35mEnter your api key:\033[33m "
read key;
echo -e -n "\033[0m"
echo -n "IyBhcGkgY29uZmlndXJhdGlvbgojIGFkZCB5b3VyIGFwaSBrZXkgaGVyZQojIGtleSA9ICcnCg==" | base64 -d > $api_conf
echo "key = '$key'" >> $api_conf
echo -e "$DAT\n" > "$dir_api/.backup"
echo -e "$key\n" >> "$dir_api/.backup"
echo -e "\033[32mdone..\033[0m"
fi