-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.sh
59 lines (56 loc) · 1.97 KB
/
setup.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
#!/bin/bash
usage()
{
cat <<- _USAGE_
Usage:
setup.sh install
- install project dependencies and vercel CLI
setup.sh login <your_email_address_with_vercel_account>
- login into vercel service
setup.sh save_token <telegram_bot_token>
- save telegram bot token
setup.sh set_webhook <your_project_url.vercel.app> <telegram_bot_token>
- communicate webhook to Telegram servers
setup.sh deploy
- deploy the app with vercel service
_USAGE_
}
##### Main
if [ $# -gt 0 ]; then
case $1 in
install ) usage
yarn install
npm install -g vercel
exit
;;
login ) if [ "$2" != "" ] ; then
vercel login $2
else
echo "Usage: ./setup.sh login <your_email_address_with_now_account>"
fi
exit
;;
save_token ) if [ "$2" != "" ] ; then
vercel secrets add jsconsole_bot_telegram_api_token $2
else
echo "Usage: ./setup.sh save_token <telegram_api_token>"
fi
exit
;;
set_webhook ) usage
if [ "$2" != "" -a "$3" != "" ] ; then
curl -F "url=$2/start_bot" https://api.telegram.org/bot$3/setWebhook
else
echo "Usage: ./setup.sh set_webhook <your_project_url.vercel.app> <telegram_api_token>"
fi
exit
;;
deploy ) vercel
exit
;;
* ) usage
exit 1
esac
else
usage
fi