feature: add connect command
This commit is contained in:
16
mc
16
mc
@@ -38,8 +38,21 @@ declare -rA commands=(
|
||||
[search]='search POST {"mod":"%s"}'
|
||||
[mod-list]='mod-list GET'
|
||||
[backup]='backup FUNC'
|
||||
[connect]='connect FUNC'
|
||||
)
|
||||
|
||||
function connect() {
|
||||
if [[ ! $(which docker) ]]; then echo "docker is required"; exit 1; fi
|
||||
docker run --rm \
|
||||
-e MODE=my-mc \
|
||||
-e PORT=25565 \
|
||||
-e HOST=0.0.0.0 \
|
||||
-e PUBLIC=false \
|
||||
-e MY_MC_API_KEY=$MY_MC_API_KEY \
|
||||
-p 25565:25565 anaxios/holesail:testing
|
||||
echo ""
|
||||
}
|
||||
|
||||
function backup() {
|
||||
if [[ ! $(which lftp) ]]; then echo "lftp is required"; exit 1; fi
|
||||
|
||||
@@ -59,7 +72,8 @@ function backup() {
|
||||
|
||||
pushd "${localdir}"
|
||||
|
||||
lftp -u "${username}","${password}" "${host}":"${port}" -e "set sftp:connect-program 'ssh -o StrictHostKeyChecking=no'; mirror -c --use-pget minecraft/ minecraft/; quit"
|
||||
lftp -u "${username}","${password}" "${host}":"${port}" \
|
||||
-e "set sftp:connect-program 'ssh -o StrictHostKeyChecking=no'; mirror -c --use-pget minecraft/ minecraft/; quit"
|
||||
|
||||
popd
|
||||
}
|
||||
|
18
mc-test.sh
18
mc-test.sh
@@ -13,6 +13,12 @@ function assert() {
|
||||
return 1
|
||||
}
|
||||
|
||||
function test_assert() {
|
||||
local string="one two three four"
|
||||
assert "$(rest ${string})" "$(rest ${string})"
|
||||
}
|
||||
test_assert
|
||||
|
||||
function first_func_returns_first_item() {
|
||||
local string="one two three four"
|
||||
assert "$(first ${string})" "one"
|
||||
@@ -38,15 +44,7 @@ function rest_func_returns_rest_items_from_array() {
|
||||
rest_func_returns_rest_items_from_array
|
||||
|
||||
function rest_func_returns_rest_items_from_array_w_spaces() {
|
||||
local a=(two "three four")
|
||||
local b=("three four")
|
||||
assert "$(rest "${a[@]}")" "three four"
|
||||
local a=(one two "three four")
|
||||
assert "$(rest ${a[@]})" "two three four"
|
||||
}
|
||||
rest_func_returns_rest_items_from_array_w_spaces
|
||||
|
||||
function rest_func_returns_rest_items_from_array_item_w_spaces_removed() {
|
||||
local a=("two three" four)
|
||||
assert "$(rest "${a[@]}")" "four"
|
||||
}
|
||||
rest_func_returns_rest_items_from_array_item_w_spaces_removed
|
||||
|
||||
|
Reference in New Issue
Block a user