forked from blrbrb/Flutterbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·159 lines (88 loc) · 2.19 KB
/
start.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#! /bin/sh
FILE=error_log.txt
check_os()
{
os_type=''
if [ "$(uname)" = "Darwin" ]; then
# Do something under Mac OS X platform
local os_typeMac="Mac"
os_type=$os_type$os_typeMac
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
local os_typeLinux="Linux"
os_type=$os_type$os_typeLinux
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
local os_typeWin32="Win32"
os_type=$os_type$os_typeWin32
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
local os_typeWin64="Win64"
os_type=$os_type$os_typeWin64
fi
}
function clear_macOSFiles()
{
if [ -f ".DS_Store" ]; then
rm .DS_Store
fi
if [ -f "commands/.DS_Store" ]; then
cd commands
rm .DS_Store
cd -
fi
if [ -f "assets/.DS_Store" ]; then
cd commands
rm .DS_Store
cd -
fi
if [ -f "utils/.DS_Store" ]; then
cd commands
rm .DS_Store
cd -
fi
}
function logmanager()
{
minimumsize=90000
actualsize=$(wc -c <$1)
if [ $actualsize -ge $minimumsize ]; then
echo log file size is over $minimumsize bytes
echo Clearing Log File…
> error_log.txt
else
echo log file size is under $minimumsize bytes
fi
}
#check to see if the error log file exists, and wether or not it has passed the size limit to be cleared and reset
if [ -f "$FILE" ]; then
echo "$FILE exists."
logmanager "$FILE"
else
echo "$FILE does not exist. Initalizing javascript error log..."
touch error_log.txt
fi
check_os
echo running fluttershy on $os_type
while true
do
tput setf 4
echo Starting Fluttershy
{
tput bold
node .
} 2>> error_log.txt
tput sgr0
echo ----------------------------------------------------------------------------------------------------- >> error_log.txt
date +"Error Generated at: %A %d %B %r" >> error_log.txt
echo There Was An Error…
cat assets/image.txt
echo Fluttershy has exited with a code of "${?}\n" 1>&2
echo details written to "$FILE"
echo Restarting Fluttershy in 15 Seconds...
sleep 15
echo -ne 'Clearing Cache: 0%)\r'
sleep 2
clear_macOSFiles
echo -ne 'Clearing Cache: 12%\r'
sleep 2
echo -ne 'Clearing Cache: 67%\r'
echo -ne "Cache Cleared! Restarting Fluttershy..."
done