This repository has been archived by the owner on Dec 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
131 lines (97 loc) · 3.28 KB
/
entrypoint.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
#!/bin/bash
# api_token=''
# function get_joplin_token(){
# api_token=$(cat /home/node/.config/joplin/settings.json | jq -r '."api.token"')
# }
# 生成id_rsa
if [ ! -f /home/node/.ssh/id_rsa ]; then
cp /root/.ssh/id_rsa /home/node/.ssh/id_rsa
chown -R node:node /home/node/.ssh/id_rsa
chmod 400 /home/node/.ssh/id_rsa
cat << EOF >> /home/node/.ssh/config
User node
EOF
fi
# 确认目录权限
chown -R node:node /home/node/.config
# 准备目录
if [ ! -d /home/node/.config/joplin ]; then
mkdir -p /home/node/.config/joplin
chown -R node:node /home/node/.config/joplin
fi
# ln -s /run/secrets/id_rsa /home/node/.ssh/id_rsa
# # 初始化
# # 设置同步
# su node -c "joplin config sync.target ${SYNC_TARGET}"
# su node -c "joplin config sync.${SYNC_TARGET}.path ${SYNC_PATH} "
# su node -c "joplin config sync.${SYNC_TARGET}.username ${SYNC_USERNAME} "
# su node -c "joplin config sync.${SYNC_TARGET}.password ${SYNC_PASSWORD} "
# su node -c "joplin config api.port 41184"
# # joplin sync
# su node -c "git config --global user.name ${GIT_USER}"
# su node -c "git config --global user.email ${GIT_EMAIL}"
# touch /home/node/.ssh/known_hosts
# ssh-keyscan github.com >> /home/node/.ssh/known_hosts
# 初始化blog
# if [ ! -d "blog" ]; then
# su node -c "git clone ${BLOG_REPOSITORY} /home/node/.config/blog"
# chown -R node:node /home/node/.config/blog
# fi
# cd blog
# su node -c "git pull"
# # 添加依赖
# su node -c "yarn add -D joplin-blog"
# su node -c "cnpm install hexo-deployer-git --save"
# su node -c "cnpm install"
# # 初始化 .joplin-blog.json
# if [ ! -f '.joplin-blog.json' ]; then
# get_joplin_token
# echo 'token:'$api_token
# su node -c "touch '.joplin-blog.json'"
# echo '{' >> '.joplin-blog.json'
# echo ' "type": "hexo", ' >> '.joplin-blog.json'
# echo ' "language": "en",' >> '.joplin-blog.json'
# echo ' "rootPath": ".",' >> '.joplin-blog.json'
# echo ' "joplinProfilePath": "/home/node/.config/joplin",' >> '.joplin-blog.json'
# echo ' "token": "'$api_token'",' >> '.joplin-blog.json'
# echo ' "port": 41184,' >> '.joplin-blog.json'
# echo ' "tag": "'${BLOG_TAG}'"' >> '.joplin-blog.json'
# echo '}' >> '.joplin-blog.json'
# echo '' >> '.joplin-blog.json'
# fi
# cursor
# cursor=-1
# get_cursor(){
# url="http://localhost:41184/events?token=$api_token"
# ret = curl $url | jq '.cursor'
# echo ret
# }
# # 启动服务
# echo start service
# su node -c "joplin server start &"
# do_update() {
# su node -c "git pull"
# new_cursor=$(get_cursor)
# if [ $new_cursor -gt $cursor ]; then
# new_cursor=$cursor
# echo begin sync
# su node -c "joplin sync"
# echo end sync
# echo begin update blog
# su node -c "yarn gen"
# echo complete update
# echo push github
# su node -c "git add ."
# su node -c "git commit -m \"commit $(date)\""
# su node -c "git push origin main"
# echo push github complete
# else
# echo 笔记没有更新,跳过笔记同步
# fi
# echo do publish...
# su node -c "yarn build"
# su node -c "yarn deploy"
# echo complete publish
# }
# while true; do do_update; sleep ${SYNC_TIME_INTERVAL}; done
su node -c "init.sh"