-
Notifications
You must be signed in to change notification settings - Fork 0
/
figgy.sh
135 lines (96 loc) · 3.35 KB
/
figgy.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
#figNET Main
#Written by: Tristan B. Kildaire (Deavmi) - ([email protected])
#License: GNU GPL v3
#Crowbar Development
function outText #Output text prefixed with `{Figgy}`
{
text=$1
echo "{Figgy}" $text
}
function getConfig #Import all the variables of the configuration file `node.conf`
{
if [ -f node.conf ]
then
source node.conf
else
outText "Could not find node configuration file."
exit
fi
}
function checkConfig #Check if all the variables in the `node.conf` configuration file have been filled out
{
if [ "$internalIP" = "" ] || [ "$internalPort" = "" ] || [ "$publicIP" = "" ] || [ "$publicPort" = "" ] || [ "$nodeName" = "" ] || [ "$nodeLocation" = "" ] || [ "$nodeOperator" = "" ] || [ "$nodeOperatorMail" = "" ] || [ "$sleepBtwnNodeSync" = "" ] || [ "$sleepBtwnNetworkSync" = "" ] || [ "$usefigCTL" = "" ] || [ "$enableFigWeb" = "" ] || [ "$figWebHomeRefresh" = "" ] || [ "$figWebServicesInfoPagesRefresh" = "" ] || [ "$figWebServicesRefresh" = "" ] || [ "$figWebNodesRefresh" = "" ] || [ "$figWebIP" = "" ] || [ "$figWebPort" = "" ]
then
outText "Configuration file 'node.conf' has variables missing values."
exit
fi
}
function importLibs #Import all the code we require
{
source figAPI.sh #Get access to all API functions (we might need the code in this script)
source figNode.sh #Get access to the web server starting function(s)
source figCTL.sh #Get access to the control console for the figNET node
source figWeb.sh #Get access to the functions in `figWeb.sh`
source figInfo.sh #Get access to variables containing info about the current release of the figNET suite
source figAutoPeer.sh #Get access to all the auto-peering-related functions
source figCleaner.sh #Get access to cleaning code
source figUpdate.sh #Get access to update code
}
function killFig #Stop this figNET node
{
echo "no" > status #Stop node syncer
}
function init #Start this figNET node
{
#-- Update code --
if [ "$updateOnStart" = "true" ]
then
outText "Importing update code..."
source figUpdate.sh #Get access to update code
outText "Update code has been imported."
outText "Updating your node with the latest software..."
outText "Removing old files..."
removeOldFiles
outText "Old files removed."
outText "Downloading new files..."
updateFiles
outText "Updated files have been downloaded."
outText "Node software has been updated."
fi
#-- End Update code --
#-- Import code to RAM code --
outText "Importing code into RAM..."
importLibs
outText "Code imported into RAM."
#-- End Import code to RAM code --
outText "Starting node..."
outText "Starting node sync..."
startNode
outText "Sync started."
#outText "Starting auto-peering system..."
#outText "Adding this node to the public nodes list..."
#addMyself
#outText "Node has been added to the public node list."
#outText "Auto-peering taking place..."
#findPeers
#outText "Auto-peering completed."
#outText "Auto-peering system started."
if [ "$enableFigWeb" = "true" ]
then
outText "Starting figWeb..."
startFigWeb
outText "figWeb started."
fi
outText "Node has been started."
outText "Enjoy figNET and be a good-moralled person. :)"
sleep 5
if [ $usefigCTL = "true" ]
then
console
else
clear
fi
}
getConfig #Import all ariables in `node.conf`
checkConfig #Check if all variables have a value other than `""`
init #Start running the node