-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
84 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function ssh_send_to_server_authorized_pub_key() { | ||
: ${1?"Usage: ${FUNCNAME[0]} <user@server>"} | ||
ssh "$1" sh -c 'cat - >> ~/.ssh/authorized_keys' <$HOME/.ssh/id_rsa.pub | ||
} | ||
|
||
function ssh_send_to_server_priv_key() { | ||
: ${1?"Usage: ${FUNCNAME[0]} <user@server>"} | ||
ssh "$1" sh -c 'cat - > ~/.ssh/id_rsa;chmod 600 $HOME/.ssh/id_rsa' <$HOME/.ssh/id_rsa | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function decompress() { | ||
: ${1?"Usage: ${FUNCNAME[0]} <zip-name> [dir-name]"} | ||
local filename=$(basename $1) | ||
local filename_noext="${filename%.*}" | ||
local extension=${path##*.} | ||
local dest | ||
if [ $# -eq 1 ]; then dest=.; else dest=$2; fi | ||
case $filename in | ||
*.tar.bz2 | *.tbz | *.tbz2) ret=$(tar -xzf "$1" -C $dest) ;; | ||
*.gz | *.Z) ret=$(gunzip "$1" >$dest/$filename_noext) ;; | ||
*.bz2) ret=$(tar -xjf "$1" -C $dest) ;; | ||
*.zip) ret=$(unzip "$1" -d $dest) ;; | ||
*.zst) ret=$(tar --use-compress-program=unzstd -xvf "$1" -C $dest) ;; | ||
*.xz) ret=$(tar -xJf "$1" -C $dest) ;; | ||
*) log_error "$extension is not supported compress." && return 1 ;; | ||
esac | ||
if [ $? != 0 ] || ! [ -f $file_name ]; then | ||
log_error "decompress "$1" failed " && return 1 | ||
fi | ||
} | ||
|
||
function decompress_from_url() { | ||
: ${2?"Usage: ${FUNCNAME[0]} <URL> <dir>"} | ||
local file_name="/tmp/$(basename $1)" | ||
if test ! -e $file_name; then | ||
log_msg "fetching "$1" to /tmp/" | ||
curl -LJ "$1" --create-dirs --output $file_name | ||
if [ $? != 0 ]; then log_error "curl fail" && return; fi | ||
fi | ||
log_msg "extracting $file_name to $2" | ||
decompress $file_name $2 | ||
} |