-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
51 lines (41 loc) · 1.3 KB
/
install.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
#!/bin/sh
# Exit immediately if a command exits with a non-zero status
set -e
# Install required packages
sudo add-apt-repository -y ppa:maxmind/ppa
sudo apt-get update
sudo apt-get install -y mysql-server geoipupdate
# Download the GeoLite2 database
sudo mkdir -p /usr/share/GeoIP
sudo geoipupdate
# Create the database and user
sudo mysql <<EOF
CREATE DATABASE achan;
CREATE USER 'achan'@'localhost' IDENTIFIED BY 'achan';
GRANT ALL PRIVILEGES ON achan.* TO 'achan'@'localhost';
FLUSH PRIVILEGES;
EOF
# Create the user
sudo useradd -m achan
# Install Go
wget https://golang.org/dl/go1.23.1.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
source ~/.profile
# Build the server
go build
# Copy to /opt/achan
sudo mkdir -p /opt/achan
sudo cp achan.moe /opt/achan
sudo cp -r banners assets views static /opt/achan
sudo mkdir -p /opt/achan/thumbs /opt/achan/certificates /opt/achan/backups
sudo cp .env.example /opt/achan/.env
sudo cp achan.service /home/achan/achan.service
sudo systemctl --user enable achan.service
sudo chmod -R 744 /opt/achan
sudo chown -R achan:achan /opt/achan
# Start the server
sudo systemctl --user daemon-reload
sudo systemctl --user start achan.service