-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-tableview.sh
More file actions
109 lines (69 loc) · 2.87 KB
/
install-tableview.sh
File metadata and controls
109 lines (69 loc) · 2.87 KB
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
#!/bin/bash
# Install Script for Table View
#----------------------------------------------------------------------
# Check user is root otherwise exit script
if [ "$EUID" -ne 0 ]
then
printf "\nPlease run as root\n\n";
exit;
fi;
cd /root;
#----------------------------------------------------------------------
# Check Table View has been cloned from GitHub
if [ ! -d "/root/table-view" ]
then
printf "\nDirectory table-view does not exist in /root.\n";
printf "Please run commands: \"cd /root; git clone https://github.com/ellwould/table-view\"\n";
printf "and run install script again\n\n";
exit;
fi;
#----------------------------------------------------------------------
# Copy unit files and reload systemd deamon
cp /root/table-view/systemd/tableview.service /usr/lib/systemd/system/;
systemctl daemon-reload;
#----------------------------------------------------------------------
# Install wget
apt update;
apt install wget;
#----------------------------------------------------------------------
# Remove any previous version of Go, download and install Go 1.24.5
wget -P https://go.dev/dl/go1.24.5.linux-amd64.tar.gz;
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.5.linux-amd64.tar.gz;
export PATH=$PATH:/usr/local/go/bin;
#----------------------------------------------------------------------
# Create HTML/CSS directory and copy HTML/CSS start and end file
mkdir -p /etc/tableview/html-css;
cp /root/table-view/html-css/* /etc/tableview/html-css/;
# Copy /root/table-view/env/tableview.env into /etc/tableview
cp /root/table-view/env/tableview.env /etc/tableview/tableview.env;
# Create Go directories in root home directory
mkdir -p /root/go/{bin,pkg,src/tableview};
# Copy Go source code
cp /root/table-view/go/tableview.go /root/go/src/tableview/tableview.go;
# Create Go mod for tableview
export PATH=$PATH:/usr/local/go/bin;
cd /root/go/src/tableview;
go mod init root/go/src/tableview;
go mod tidy;
# Compile tableview.go
cd /root/go/src/tableview;
go build tableview.go;
cd /root;
# Create system user named tableview with no shell, no home directory and lock account
useradd -r -s /bin/false tableview;
usermod -L tableview;
# Change executables file permissions, owner, group and move executables
chown root:tableview /root/go/src/tableview/tableview;
chmod 050 /root/go/src/tableview/tableview;
mv /root/go/src/tableview/tableview /usr/bin/tableview;
# Change tableviewresource file permissions, owner and group
chown -R root:tableview /etc/tableview;
chmod 050 /etc/tableview;
chmod 040 /etc/tableview/tableview.env;
chmod 050 /etc/tableview/html-css;
chmod 040 /etc/tableview/html-css/*;
# Enable tableview on boot
systemctl enable tableview;
#----------------------------------------------------------------------
printf "\nUpdate database details in /etc/tableview/tableview.env\n";
printf "\nThen to start Table View run: systemctl start tableview\n";