|
170 | 170 | mkdir -p /etc/auth.d
|
171 | 171 | mkdir -p /etc/gotrue
|
172 | 172 |
|
173 |
| - # Create gotrue user if it doesn't exist |
174 |
| - if ! id "gotrue" &>/dev/null; then |
175 |
| - useradd -r -s /bin/false gotrue |
176 |
| - fi |
177 |
| -
|
178 | 173 | # Set proper ownership
|
179 | 174 | chown -R gotrue:gotrue /opt/gotrue
|
180 | 175 | chown -R gotrue:gotrue /etc/auth.d
|
|
185 | 180 | chmod 775 /etc/auth.d
|
186 | 181 | chmod 775 /etc/gotrue
|
187 | 182 |
|
188 |
| - # Copy the binary |
| 183 | + # Copy the binary to the correct location |
189 | 184 | cp ${auth-service}/bin/supabase-auth /opt/gotrue/gotrue
|
190 | 185 | chown gotrue:gotrue /opt/gotrue/gotrue
|
191 | 186 | chmod 755 /opt/gotrue/gotrue
|
|
194 | 189 | cp $out/lib/systemd/system/gotrue.service /etc/systemd/system/
|
195 | 190 | chmod 644 /etc/systemd/system/gotrue.service
|
196 | 191 |
|
197 |
| - # Copy the environment file |
198 |
| - cp $out/etc/auth.env /etc/gotrue.generated.env |
199 |
| - chown gotrue:gotrue /etc/gotrue.generated.env |
200 |
| - chmod 600 /etc/gotrue.generated.env |
201 |
| -
|
202 |
| - # Create symlinks for easy access |
203 |
| - ln -sf $out/bin/manage-auth /usr/local/bin/gotrue-manage |
204 |
| - ln -sf $out/share/gotrue/gotrue.service /usr/local/share/gotrue/gotrue.service |
205 |
| - ln -sf $out/bin/activate /usr/local/bin/auth-activate |
| 192 | + # Copy the environment file to the correct location |
| 193 | + cp $out/etc/auth.env /etc/auth.d/20_generated.env |
| 194 | + chown gotrue:gotrue /etc/auth.d/20_generated.env |
| 195 | + chmod 600 /etc/auth.d/20_generated.env |
| 196 | +
|
| 197 | + # Create symlinks for easy access from nix profile |
| 198 | + mkdir -p /usr/local/bin |
| 199 | + mkdir -p /usr/local/share/gotrue |
| 200 | +
|
| 201 | + # Create symlinks to the nix profile locations |
| 202 | + ln -sf "\$NIX_PROFILE/bin/manage-auth" /usr/local/bin/gotrue-manage |
| 203 | + ln -sf "\$NIX_PROFILE/share/gotrue/gotrue.service" /usr/local/share/gotrue/gotrue.service |
| 204 | + ln -sf "\$NIX_PROFILE/bin/activate" /usr/local/bin/auth-activate |
| 205 | + ln -sf "\$NIX_PROFILE/bin/gotrue" /usr/local/bin/gotrue |
| 206 | +
|
| 207 | + # Allow UFW connections to GoTrue metrics exporter if UFW is installed |
| 208 | + if command -v ufw >/dev/null 2>&1; then |
| 209 | + ufw allow 9122/tcp comment "GoTrue metrics exporter" |
| 210 | + echo "Added UFW rule for GoTrue metrics exporter" |
| 211 | + fi |
206 | 212 |
|
207 | 213 | # Reload systemd
|
208 | 214 | systemctl daemon-reload
|
|
213 | 219 |
|
214 | 220 | echo "Gotrue service has been activated and started"
|
215 | 221 | echo "You can manage the service using: gotrue-manage {start|stop|restart|status}"
|
| 222 | + echo "The following commands are available:" |
| 223 | + echo " gotrue-manage - Manage the Gotrue service" |
| 224 | + echo " auth-activate - Run this activation script again" |
| 225 | + echo " gotrue - The auth service binary" |
216 | 226 | EOF
|
217 | 227 | chmod +x $out/bin/activate
|
218 | 228 |
|
219 | 229 | # Create symlinks to the systemd unit files for easy access
|
220 | 230 | mkdir -p $out/share/gotrue
|
221 | 231 | ln -s $out/lib/systemd/system/gotrue.service $out/share/gotrue/gotrue.service
|
| 232 | +
|
| 233 | + # Copy the auth binary to the package's bin directory |
| 234 | + cp ${auth-service}/bin/supabase-auth $out/bin/gotrue |
| 235 | + chmod +x $out/bin/gotrue |
222 | 236 | '';
|
223 | 237 |
|
224 | 238 | installPhase = "true";
|
|
0 commit comments