summaryrefslogtreecommitdiffstats
path: root/services/bin/services
blob: c142a363b84d8d25b12420a58fbb39015bbb9418 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /bin/sh
# usage: services [user@]hostname[:port]
# environment:
#   services_identity_file  path to ssh(1) identity_file
set -euf

user=services
hostname=${1-localhost}
port=1337

if test -n "${services_identity_file-}"; then
  options="${options+$options }-i $services_identity_file"
fi

if echo $hostname | grep -q @; then
  user=`echo $hostname | cut -d@ -f1`
  hostname=`echo $hostname | cut -d@ -f2`
fi
if echo $hostname | grep -q :; then
  port=`echo $hostname | cut -d: -f2`
  hostname=`echo $hostname | cut -d: -f1`
fi

ssh $options $user@$hostname -p $port