add option for private key path in sync database

This commit is contained in:
ksyasuda 2021-11-11 14:36:04 -08:00
parent 4853dea3d5
commit 65511a2961
3 changed files with 44 additions and 33 deletions

66
ani-cli
View File

@ -541,37 +541,7 @@ while getopts 'hd:HlpadP:s' OPT; do
exit 0 exit 0
;; ;;
s) s)
printf "%s" "Enter username for remote user: " scrape=sync
read -r username
printf "%s" "Enter host for remote user: "
read -r host
# printf "%s" "Enter connection string for remote user in the form user@host: "
# read -r connection_str
connection_str="$username@$host"
printf "%s" "Enter port to connect to remote host with or leave blank for default (22): "
read -r port
if [[ "${port/ //}" == "" ]]; then
PORT=22
else
PORT="$port"
fi
if [[ ! "@" != *"$connection_str" ]]; then
printf "%s\n" "Enter in full connection string to remote user in the form: user@host"
exit 1
fi
printf "%s\n" "Syncing database with: $connection_str on port $PORT"
temp_db="/tmp/aniwrapper_tmp_history.sqlite3"
scp -P "$PORT" "$connection_str:$XDG_CONFIG_HOME/aniwrapper/history.sqlite3" "$temp_db"
if [[ "$?" -ne 0 ]]; then
printf "%s\n" "Error getting database file from remote host"
exit 1
fi
sync_search_history && sync_watch_history
exit 0
;; ;;
*) *)
printf "%s\n" "Invalid option" printf "%s\n" "Invalid option"
@ -654,7 +624,41 @@ case $scrape in
episode_selection episode_selection
;; ;;
delete) ;; delete) ;;
sync)
printf "%s" "Enter username for remote user: "
read -r username
printf "%s" "Enter host for remote user: "
read -r host
# printf "%s" "Enter connection string for remote user in the form user@host: "
# read -r connection_str
connection_str="$username@$host"
printf "%s" "Enter port to connect to remote host with or leave blank for default (22): "
read -r port
if [[ "${port/ //}" == "" ]]; then
PORT=22
else
PORT="$port"
fi
printf "%s" "Enter path to private key (leave blank if unsure or not needed): "
read -r key_path
printf "%s\n" "Syncing database with: $connection_str on port $PORT"
temp_db="/tmp/aniwrapper_tmp_history.sqlite3"
if [[ -z "$key_path" ]]; then
scp -P "$PORT" "$connection_str:$XDG_CONFIG_HOME/aniwrapper/history.sqlite3" "$temp_db"
else
scp -P "$PORT" -i "$key_path" "$connection_str:$XDG_CONFIG_HOME/aniwrapper/history.sqlite3" "$temp_db"
fi
if [[ "$?" -ne 0 ]]; then
printf "%s\n" "Error getting database file from remote host"
exit 1
fi
sync_search_history && sync_watch_history
exit 0
;;
esac esac
{ # checking input { # checking input

View File

@ -162,7 +162,14 @@ case "$selection" in
if [[ -z "$port" ]] || [[ "$port" == "" ]]; then if [[ -z "$port" ]] || [[ "$port" == "" ]]; then
port=22 port=22
fi fi
printf "%s\n%s\n%d\n" "$username" "$host" "$port" | ani-cli -s keypath=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
-l 1 -p "Enter path to private key (leave blank if not needed or if unsure):")
if [[ -z "$keypath" ]]; then
printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "" | ani-cli -s
else
printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "$keypath" | ani-cli -s
fi
if [[ "$?" -ne 0 ]]; then if [[ "$?" -ne 0 ]]; then
log "Aniwrapper was unable to sync the databases..." log "Aniwrapper was unable to sync the databases..."
exit 1 exit 1

View File

@ -191,6 +191,6 @@ textbox-prompt-colon {
expand: false; expand: false;
str: ":"; str: ":";
margin: 0px 0.3em 0em 0em ; margin: 0px 0.3em 0em 0em ;
text-color: #1E90FF; text-color: #c678dd;
padding: 4px 0px; padding: 4px 0px;
} }