-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.sh
28 lines (23 loc) · 818 Bytes
/
script.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
function hb() {
user="deploy"
address="xxx.xxx.xxx.xxx" # REPLACE ME
if [[ $# < 2 ]]; then
echo "HatchBox CLI: Must provide an app slug and command, e.g hb <app> <command>"
echo ""
echo "Available commands:"
echo "hb <app> console Run rails console for <app>"
echo "hb <app> logs Read live logs for <app>"
return
fi
app=${1}
action=${2}
if [[ ${action} == 'logs' ]]; then
echo "tailing the ${app} logs..."
action="journalctl --user --unit=${app}-server" # HatchBox v2.0
# action="tail -f ~/${app}/current/log/production.log" # enable for HatchBox Classic
elif [[ ${action} == 'console' ]]; then
echo "opening the ${app} console..."
action="cd ~/${app}/current && bundle exec rails console"
fi
ssh -t ${user}@${address} ${action}
}