2022-09-02 11:09:24 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# https://gist.github.com/anthonyaxenov/89c99e09ddb195985707e2b24a57257d
|
|
|
|
|
|
|
|
CONTAINER="iptv-php" # the name of the container in which to 'exec' something
|
|
|
|
CONFIG="$(dirname $([ -L $0 ] && readlink -f $0 || echo $0))/docker-compose.yml" # path to compose yml file
|
|
|
|
CMD="docker-compose -f $CONFIG" # docker-compose command
|
|
|
|
APP_URL='http://localhost:8080/'
|
|
|
|
|
|
|
|
open_browser() {
|
|
|
|
if which xdg-open > /dev/null; then
|
|
|
|
xdg-open "$1" </dev/null >/dev/null 2>&1 & disown
|
|
|
|
elif which gnome-open > /dev/null; then
|
|
|
|
gnome-open "$1" </dev/null >/dev/null 2>&1 & disown
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
2022-09-12 14:34:05 +00:00
|
|
|
'' | 'help' ) echo -e "Provide one of operations: \t init, start, stop, up, down, restart, rebuild, open, hooks";
|
2022-09-02 11:09:24 +00:00
|
|
|
echo "Otherwise all args will passed to 'docker exec -ti $CONTAINER ...'" ;;
|
2022-09-12 14:34:05 +00:00
|
|
|
'init' ) cp src/.env.example src/.env && \
|
|
|
|
./iptv hooks && \
|
|
|
|
./iptv up && \
|
|
|
|
./iptv composer i && \
|
|
|
|
echo "Project started successfully! $APP_URL" ;;
|
2022-09-02 11:09:24 +00:00
|
|
|
'up' ) $CMD up -d --build && ./iptv open ;; # build and start containers
|
|
|
|
'down' ) $CMD down --remove-orphans ;; # stop and remove containers
|
2022-09-12 14:34:05 +00:00
|
|
|
'start' ) $CMD start ;; # start containers
|
2022-09-02 11:09:24 +00:00
|
|
|
'stop' ) $CMD stop ;; # stop containers
|
|
|
|
'restart' ) $CMD stop && $CMD start ;; # restart containers
|
|
|
|
'rebuild' ) $CMD down --remove-orphans && $CMD up -d --build ;; # rebuild containers
|
2022-09-12 14:34:05 +00:00
|
|
|
'open' ) open_browser $APP_URL && echo -e "\nYou're welcome!\n\t$APP_URL" ;;
|
|
|
|
'hooks' ) ./hooks/post-commit && cp hooks/* .git/hooks ;;
|
|
|
|
* ) docker exec -ti $CONTAINER $* ;; # exec anything else in container
|
2022-09-02 11:09:24 +00:00
|
|
|
esac
|