mirror of
http://gitea.phreedom.club/localhost_frssoft/pleroma-cli
synced 2024-11-24 13:41:27 +00:00
Delete code dublicates
This commit is contained in:
parent
fb20b6c0ed
commit
85d465d8c3
104
pleroma-cli.sh
104
pleroma-cli.sh
|
@ -2,16 +2,22 @@
|
||||||
|
|
||||||
instance=$(jj -i config.json instance)
|
instance=$(jj -i config.json instance)
|
||||||
alias default_auth_browser=links
|
alias default_auth_browser=links
|
||||||
if [ $(echo "$instance" | grep -q 'i2p$' ; echo $?) -eq 0 ]; then
|
|
||||||
default_connect_protocol='http'
|
proxy_init()
|
||||||
proxy=$(jj -i config.json i2p_http_proxy_addr)
|
{
|
||||||
elif [ $(echo "$instance" | grep -q 'onion$'; echo $?) -eq 0 ]; then
|
if [ $(echo "$instance" | grep -q 'i2p$' ; echo $?) -eq 0 ]; then
|
||||||
default_connect_protocol='https'
|
default_connect_protocol='http'
|
||||||
proxy=$(jj -i config.json tor_proxy_addr)
|
proxy=$(jj -i config.json i2p_http_proxy_addr)
|
||||||
else
|
elif [ $(echo "$instance" | grep -q 'onion$'; echo $?) -eq 0 ]; then
|
||||||
default_connect_protocol='https'
|
default_connect_protocol='https'
|
||||||
proxy=''
|
proxy=$(jj -i config.json tor_proxy_addr)
|
||||||
fi
|
else
|
||||||
|
default_connect_protocol='https'
|
||||||
|
proxy=''
|
||||||
|
fi
|
||||||
|
export default_connect_protocol
|
||||||
|
export proxy
|
||||||
|
}
|
||||||
instance_point="$default_connect_protocol://$instance/api/v1"
|
instance_point="$default_connect_protocol://$instance/api/v1"
|
||||||
instance_point_pleroma="$default_connect_protocol://$instance/api/pleroma"
|
instance_point_pleroma="$default_connect_protocol://$instance/api/pleroma"
|
||||||
instance_hist='instance.hist'
|
instance_hist='instance.hist'
|
||||||
|
@ -32,25 +38,34 @@ per_status_mode=$(jj -i config.json per_status_mode)
|
||||||
mkdir -m 711 -p .app_sessions
|
mkdir -m 711 -p .app_sessions
|
||||||
touch .auth.json
|
touch .auth.json
|
||||||
chmod 600 .auth.json
|
chmod 600 .auth.json
|
||||||
auth="$(jj -i .auth.json "$(echo "$instance" | sed 's/\./\\\./g')")"
|
|
||||||
echo "Instance: $instance"
|
make_login()
|
||||||
if [ -n "$auth" ]; then
|
{
|
||||||
default_curl_opt()
|
auth="$(jj -i .auth.json "$(echo "$instance" | sed 's/\./\\\./g')")"
|
||||||
{
|
echo "Instance: $instance"
|
||||||
curl --proxy "$proxy" -s --compressed -H "Authorization: Bearer $auth" "$@"
|
if [ -n "$auth" ]; then
|
||||||
}
|
default_curl_opt()
|
||||||
post_request()
|
{
|
||||||
{
|
curl --proxy "$proxy" -s --compressed -H "Authorization: Bearer $auth" "$@"
|
||||||
curl --proxy "$proxy" -s --compressed -X POST -H "Authorization: Bearer $auth" "$@"
|
}
|
||||||
}
|
post_request()
|
||||||
echo '+Authorized account+'
|
{
|
||||||
else
|
curl --proxy "$proxy" -s --compressed -X POST -H "Authorization: Bearer $auth" "$@"
|
||||||
default_curl_opt()
|
}
|
||||||
{
|
echo '+Authorized account+'
|
||||||
curl --proxy "$proxy" -s --compressed "$1"
|
export default_curl_opt
|
||||||
}
|
export post_request
|
||||||
echo 'Please make auth and restart'
|
else
|
||||||
fi
|
default_curl_opt()
|
||||||
|
{
|
||||||
|
curl --proxy "$proxy" -s --compressed "$1"
|
||||||
|
}
|
||||||
|
export default_curl_opt
|
||||||
|
export post_request=
|
||||||
|
echo 'Please make auth and restart'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
make_login
|
||||||
|
|
||||||
auth_api_create_client()
|
auth_api_create_client()
|
||||||
{
|
{
|
||||||
|
@ -841,16 +856,7 @@ case $main_menu in
|
||||||
if [ $empty -eq 0 ]; then
|
if [ $empty -eq 0 ]; then
|
||||||
echo "$instance" >> $instance_hist
|
echo "$instance" >> $instance_hist
|
||||||
cat $instance_hist | sort | uniq | tee $instance_hist 1>>/dev/null
|
cat $instance_hist | sort | uniq | tee $instance_hist 1>>/dev/null
|
||||||
if [ $(echo "$instance" | grep -q 'i2p$'; echo $?) -eq 0 ]; then
|
proxy_init
|
||||||
default_connect_protocol='http'
|
|
||||||
proxy=$(jj -i config.json i2p_http_proxy_addr)
|
|
||||||
elif [ $(echo "$instance" | grep -q 'onion$'; echo $?) -eq 0 ]; then
|
|
||||||
default_connect_protocol='https'
|
|
||||||
proxy=$(jj -i config.json tor_proxy_addr)
|
|
||||||
else
|
|
||||||
default_connect_protocol='https'
|
|
||||||
proxy=
|
|
||||||
fi
|
|
||||||
instance_point="$default_connect_protocol://$instance/api/v1"
|
instance_point="$default_connect_protocol://$instance/api/v1"
|
||||||
instance_point_pleroma="$default_connect_protocol://$instance/api/pleroma"
|
instance_point_pleroma="$default_connect_protocol://$instance/api/pleroma"
|
||||||
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
|
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
|
||||||
|
@ -860,25 +866,7 @@ case $main_menu in
|
||||||
echo ''
|
echo ''
|
||||||
fi
|
fi
|
||||||
clear
|
clear
|
||||||
auth="$(jj -i .auth.json "$(echo "$instance" | sed 's/\./\\\./g')")"
|
make_login
|
||||||
echo "Instance: $instance"
|
|
||||||
if [ -n "$auth" ]; then
|
|
||||||
default_curl_opt()
|
|
||||||
{
|
|
||||||
curl --proxy "$proxy" -s --compressed -H "Authorization: Bearer $auth" "$@"
|
|
||||||
}
|
|
||||||
post_request()
|
|
||||||
{
|
|
||||||
curl --proxy "$proxy" -s --compressed -X POST -H "Authorization: Bearer $auth" "$@"
|
|
||||||
}
|
|
||||||
echo '+Authorized account+'
|
|
||||||
else
|
|
||||||
default_curl_opt()
|
|
||||||
{
|
|
||||||
curl --proxy "$proxy" -s --compressed "$1"
|
|
||||||
}
|
|
||||||
echo 'Please make auth and restart'
|
|
||||||
fi
|
|
||||||
fi ;;
|
fi ;;
|
||||||
"$authmake") auth_api_get_token ;;
|
"$authmake") auth_api_get_token ;;
|
||||||
"$Exit") exit 0 ;;
|
"$Exit") exit 0 ;;
|
||||||
|
|
Loading…
Reference in a new issue