-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservices.sh
More file actions
107 lines (103 loc) · 3.42 KB
/
Copy pathservices.sh
File metadata and controls
107 lines (103 loc) · 3.42 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
#!/bin/bash
# usage : ./start.sh <start | stop | restart | status | setup> <service name>
#array of services (searx, whoogle, matrix)
services=(searx whoogle matrix element)
# help function
function help {
echo "Usage: ./start.sh <start | stop | restart | status | setup> <service name>"
echo "Services:"
for i in "${services[@]}"
do
echo " $i"
done
}
# if <start | stop | restart | status> is not specified, then print error
if [ -z "$1" ]; then
echo "Error: command is not specified"
help
exit 1
fi
if [[ "$1" = "help" || "$1" = "-h" || "$1" = "--help" ]]; then
help
exit 0
fi
# if <start | stop | restart | status...> is not valid, then print error
if [[ "$1" != "start" && "$1" != "stop" && "$1" != "restart" && "$1" != "setup" && "$1" != "status" && "$1" != "logs" ]]; then
echo "Error: command is not valid"
help
exit 1
fi
# if setup is specified, then run setup.sh
if [ "$1" = "setup" ]; then
echo "Setting up searxng-docker..."
# clone https://github.com/searxng/searxng-docker.git to searxng-docker..
git clone https://github.com/searxng/searxng-docker.git
# ask for the domain name and set it to the variable domain
read -p "Enter the domain name: " domain
# ask for the email and set it to the variable email
read -p "Enter the email: " email
# set secutiry key and then write to searxng-docker/.env
sed -i "s|ultrasecretkey|$(openssl rand -hex 32)|g" searxng-docker/searxng/settings.yml
echo "SEARXNG_HOSTNAME=$domain" > searxng-docker/.env
echo "LETSENCRYPT_EMAIL=$email" >> searxng-docker/.env
exit 0
fi
# if <service name> is not specified, then print error
if [ -z "$2" ]; then
echo "Error: service name is not specified"
help
exit 1
fi
if [[ ! " ${services[@]} " =~ " $2 " ]]; then
echo "Error: service name is not valid"
help
exit 1
fi
# for searx
if [ "$2" = "searx" ]; then
if [ "$1" = "start" ]; then
cd searxng-docker
docker-compose up -d
elif [ "$1" = "stop" ]; then
cd searxng-docker
docker-compose down
elif [ "$1" = "restart" ]; then
cd searxng-docker
docker-compose down
docker-compose up -d
elif [ "$1" = "status" ]; then
cd searxng-docker
docker-compose ps
elif [ "$1" = "logs" ]; then
cd searxng-docker
docker-compose logs -f
fi
fi
# for matrix;
if [ "$2" = "matrix" ]; then
if [ "$1" = "start" ]; then
docker run -it --rm -d --name synapse -v $PWD/matrix/data:/data -e SYNAPSE_SERVER_NAME=matrix.jimni.live -e SYNAPSE_SERVER_NAME -p 8008:8008 matrixdotorg/synapse:latest
elif [ "$1" = "stop" ]; then
docker stop synapse
elif [ "$1" = "restart" ]; then
docker restart synapse
elif [ "$1" = "status" ]; then
docker ps | grep synapse
elif [ "$1" = "logs" ]; then
docker logs -f synapse
fi
fi
# for element; docker run -p 80:80 -v /etc/element-web/config.json:/app/config.json vectorim/element-web
if [ "$2" = "element" ]; then
if [ "$1" = "start" ]; then
docker run -it --rm -d --name element -v $PWD/element/config.json:/app/config.json -p 8009:80 vectorim/element-web
elif [ "$1" = "stop" ]; then
docker stop element
elif [ "$1" = "restart" ]; then
docker restart element
elif [ "$1" = "status" ]; then
docker ps | grep element
elif [ "$1" = "logs" ]; then
docker logs -f element
fi
fi