forked from kingwrcy/moments
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinstall.sh
81 lines (58 loc) · 1.9 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
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
#!/bin/bash
install_ubuntu_packages() {
sudo apt-get update
sudo apt-get install -y curl redis-server libheif-examples
}
install_centos_packages() {
sudo yum install -y epel-release
sudo yum install -y redis curl libheif-examples
}
install_node() {
if ! command -v node &> /dev/null || [ "$(node -v | sed 's/v//')" \< "16" ]; then
echo "Installing NVM and Node.js LTS version..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install --lts
fi
}
if grep -qEi "(debian|ubuntu)" /etc/*release; then
install_ubuntu_packages
elif grep -qEi "(centos|red hat|redhat)" /etc/*release; then
install_centos_packages
fi
install_node
sudo mkdir -p /opt/moments
cd /opt/moments
git clone https://github.com/RandallAnjie/moments.git
cd moments
npm install
npx prisma migrate dev
npm run build
curl -o data/db.sqlite https://randallanjie.com/download/db.sqlite
echo "[Unit]
Description = moments
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
WorkingDirectory=/opt/moments/moments
ExecStart = $(which node) /opt/moments/moments/.output/server/index.mjs
EnvironmentFile = /opt/moments/moments/.env
[Install]
WantedBy = multi-user.target
" | sudo tee /etc/systemd/system/moments.service
sudo systemctl daemon-reload
sudo systemctl start moments
sudo systemctl enable moments
clear
echo "Moments 安装成功!"
echo "systemctl start moments 来启动服务"
echo "systemctl stop moments 来停止服务"
echo "systemctl restart moments 来重启服务"
echo "systemctl status moments 来查看服务状态"
echo "systemctl enable moments 来开机自启"
echo "systemctl disable moments 来关闭开机自启"
echo " "
echo " "