-
Notifications
You must be signed in to change notification settings - Fork 26
/
run-webservice.sh
executable file
·125 lines (106 loc) · 3.57 KB
/
run-webservice.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
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix bash jq
#
# To quickly run a web service you can use the following command:
#
# nix-build run-webservice.nix -A leaps
#
# If you want to provide more options, you can pass them using --arg and
# wsConfig:
#
# nix-build run-webservice.nix \
# --arg wsConfig '{ defaultSkin = "nostalgia" }' \
# -A mediawiki
#
# The result is script that spawns a QEMU VM and automatically forwards ports
# so that the web service is accessible by pointing your browser at
# http://localhost:3000/. A SSH session is also started and automatically
# connected to the guest VM via the root user.
#
# Emails sent from web services are all caught under the root user's mailbox,
# so simply invoking "mutt" will give you access to all mails that were sent
# out by the web service.
#
# Running the VM is a matter of just executing the resulting store path, which
# by default is "./result".
#
# Note that a file called "nixcloud-dev.qcow2" is created when running the VM,
# which contains the disk state for the guest system. If you want to get rid of
# all state and start fresh, simple delete the file and run again.
set -e
pushd "$(dirname "$0")" > /dev/null
printAvailable() {
echo "Available web service names are:" >&2
echo >&2
eval "$(nix-instantiate --eval --strict --json -E '
builtins.attrNames (import ./run-webservice.nix {})
' | jq -r '@sh "for i in \(.); do echo \" * $i\" >&2; done"')"
echo >&2
}
printUsage() {
cat >&2 <<EOF
$0 [options] [--] webservice_name [qemu_args]
This is a helper tool which should aid in development of new modules. It can
also be used to take a quick look at what a web service does and to play around
with it.
To quickly run a web service you can run it like this for the Leaps service:
$0 leaps
You can also provide more configuration options which are applied to the web