@@ -31,12 +31,12 @@ check_dependencies() {
31
31
if ! exists curl; then
32
32
error " curl is not installed."
33
33
exit 1
34
- fi
34
+ fi
35
35
36
36
if ! exists docker; then
37
37
error " docker is not installed."
38
38
exit 1
39
- fi
39
+ fi
40
40
41
41
if ! exists docker-compose; then
42
42
error " docker-compose is not installed."
@@ -45,81 +45,81 @@ check_dependencies() {
45
45
}
46
46
47
47
download () {
48
- curl --fail --silent --location --output " $2 " " $1 "
48
+ curl --fail --silent --location --output " $2 " " $1 "
49
49
}
50
50
51
51
is_healthy () {
52
- info " waiting for db container to be up. retrying in 3s"
53
- health_status=" $( docker inspect -f " {{.State.Health.Status}}" " $1 " ) "
54
- if [ " $health_status " = " healthy" ]; then
55
- return 0
56
- else
57
- return 1
58
- fi
52
+ info " waiting for db container to be up. retrying in 3s"
53
+ health_status=" $( docker inspect -f " {{.State.Health.Status}}" " $1 " ) "
54
+ if [ " $health_status " = " healthy" ]; then
55
+ return 0
56
+ else
57
+ return 1
58
+ fi
59
59
}
60
60
61
61
is_running () {
62
- info " checking if " $1 " is running"
63
- status=" $( docker inspect -f " {{.State.Status}}" " $1 " ) "
64
- if [ " $status " = " running" ]; then
65
- return 0
66
- else
67
- return 1
68
- fi
62
+ info " checking if " $1 " is running"
63
+ status=" $( docker inspect -f " {{.State.Status}}" " $1 " ) "
64
+ if [ " $status " = " running" ]; then
65
+ return 0
66
+ else
67
+ return 1
68
+ fi
69
69
}
70
70
71
71
generate_password (){
72
- echo $( tr -dc A-Za-z0-9 < /dev/urandom | head -c 13 ; echo ' ' )
72
+ echo $( tr -dc A-Za-z0-9 < /dev/urandom | head -c 13 ; echo ' ' )
73
73
}
74
74
75
75
get_config () {
76
- info " fetching config.toml from listmonk repo"
77
- download https://raw.githubusercontent.com/knadh/listmonk/master/config.toml.sample config.toml
76
+ info " fetching config.toml from listmonk repo"
77
+ download https://raw.githubusercontent.com/knadh/listmonk/master/config.toml.sample config.toml
78
78
}
79
79
80
80
get_containers () {
81
- info " fetching docker-compose.yml from listmonk repo"
82
- download https://raw.githubusercontent.com/knadh/listmonk/master/docker-compose.yml docker-compose.yml
81
+ info " fetching docker-compose.yml from listmonk repo"
82
+ download https://raw.githubusercontent.com/knadh/listmonk/master/docker-compose.yml docker-compose.yml
83
83
}
84
84
85
85
modify_config (){
86
- info " generating a random password"
87
- db_password=$( generate_password)
88
-
89
- info " modifying config.toml"
90
- # Replace `db.host=localhost` with `db.host=db` in config file.
91
- sed -i " s/host = \" localhost\" /host = \" listmonk_db\" /g" config.toml
92
- # Replace `db.password=listmonk` with `db.password={{db_password}}` in config file.
93
- # Note that `password` is wrapped with `\b`. This ensures that `admin_password` doesn't match this pattern instead.
94
- sed -i " s/\bpassword\b = \" listmonk\" /password = \" $db_password \" /g" config.toml
95
- # Replace `app.address=localhost:9000` with `app.address=0.0.0.0:9000` in config file.
96
- sed -i " s/address = \" localhost:9000\" /address = \" 0.0.0.0:9000\" /g" config.toml
97
-
98
- info " modifying docker-compose.yml"
99
- sed -i " s/POSTGRES_PASSWORD=listmonk/POSTGRES_PASSWORD=$db_password /g" docker-compose.yml
86
+ info " generating a random password"
87
+ db_password=$( generate_password)
88
+
89
+ info " modifying config.toml"
90
+ # Replace `db.host=localhost` with `db.host=db` in config file.
91
+ sed -i " s/host = \" localhost\" /host = \" listmonk_db\" /g" config.toml
92
+ # Replace `db.password=listmonk` with `db.password={{db_password}}` in config file.
93
+ # Note that `password` is wrapped with `\b`. This ensures that `admin_password` doesn't match this pattern instead.
94
+ sed -i " s/\bpassword\b = \" listmonk\" /password = \" $db_password \" /g" config.toml
95
+ # Replace `app.address=localhost:9000` with `app.address=0.0.0.0:9000` in config file.
96
+ sed -i " s/address = \" localhost:9000\" /address = \" 0.0.0.0:9000\" /g" config.toml
97
+
98
+ info " modifying docker-compose.yml"
99
+ sed -i " s/POSTGRES_PASSWORD=listmonk/POSTGRES_PASSWORD=$db_password /g" docker-compose.yml
100
100
}
101
101
102
102
run_migrations (){
103
- info " running migrations"
104
- docker-compose up -d db
105
- while ! is_healthy listmonk_db; do sleep 3; done
106
- docker-compose run --rm app ./listmonk --install
103
+ info " running migrations"
104
+ docker-compose up -d db
105
+ while ! is_healthy listmonk_db; do sleep 3; done
106
+ docker-compose run --rm app ./listmonk --install
107
107
}
108
108
109
109
start_services (){
110
- info " starting app"
111
- docker-compose up -d app db
110
+ info " starting app"
111
+ docker-compose up -d app db
112
112
}
113
113
114
114
show_output (){
115
- info " finishing setup"
116
- sleep 3
117
-
118
- if is_running listmonk_db && is_running listmonk_app
119
- then completed " Listmonk is now up and running. Visit http://localhost:9000 in your browser."
120
- else
121
- error " error running containers. something went wrong."
122
- fi
115
+ info " finishing setup"
116
+ sleep 3
117
+
118
+ if is_running listmonk_db && is_running listmonk_app
119
+ then completed " Listmonk is now up and running. Visit http://localhost:9000 in your browser."
120
+ else
121
+ error " error running containers. something went wrong."
122
+ fi
123
123
}
124
124
125
125
0 commit comments