optimize scripts
This commit is contained in:
parent
e97484cf9d
commit
755b41e474
|
@ -8,22 +8,30 @@ build_time=`date +%Y-%m-%dT%H:%M:%S.000%z`
|
||||||
device_info=`uname -s -n -m`
|
device_info=`uname -s -n -m`
|
||||||
|
|
||||||
#--------------- Geo info ----------------#
|
#--------------- Geo info ----------------#
|
||||||
curl ipinfo.io > ip_info.txt # get IP info
|
if [ ! -f "/tmp/ip_info.tmp" ]; then
|
||||||
|
curl ipinfo.io > /tmp/ip_info.tmp # get IP info
|
||||||
|
fi
|
||||||
|
|
||||||
grep city ip_info.txt > ip_city.txt # filter city
|
if [ ! -f "/tmp/ip_city.tmp" ]; then
|
||||||
sed -i 's/"city"://g' ip_city.txt #remove property name
|
grep city /tmp/ip_info.tmp > /tmp/ip_city.tmp # filter city
|
||||||
sed -i 's/"//g' ip_city.txt #remove double quotes
|
sed -i 's/"city"://g' /tmp/ip_city.tmp #remove property name
|
||||||
city=`sed 's/,//g' ip_city.txt` #remove comma
|
sed -i 's/"//g' /tmp/ip_city.tmp #remove double quotes
|
||||||
|
fi
|
||||||
|
city=`sed 's/,//g' /tmp/ip_city.tmp` #remove comma
|
||||||
|
|
||||||
grep country ip_info.txt > ip_country.txt # filter country
|
if [ ! -f "/tmp/ip_country.tmp" ]; then
|
||||||
sed -i 's/"country"://g' ip_country.txt #remove property name
|
grep country /tmp/ip_info.tmp > /tmp/ip_country.tmp # filter country
|
||||||
sed -i 's/"//g' ip_country.txt #remove double quotes
|
sed -i 's/"country"://g' /tmp/ip_country.tmp #remove property name
|
||||||
country=`sed 's/,//g' ip_country.txt` #remove comma
|
sed -i 's/"//g' /tmp/ip_country.tmp #remove double quotes
|
||||||
|
fi
|
||||||
|
country=`sed 's/,//g' /tmp/ip_country.tmp` #remove comma
|
||||||
|
|
||||||
grep org ip_info.txt > ip_org.txt # filter org
|
if [ ! -f "/tmp/ip_org.tmp" ]; then
|
||||||
sed -i 's/"org"://g' ip_org.txt #remove property name
|
grep org /tmp/ip_info.tmp > /tmp/ip_org.tmp # filter org
|
||||||
sed -i 's/"//g' ip_org.txt #remove double quotes
|
sed -i 's/"org"://g' /tmp/ip_org.tmp #remove property name
|
||||||
org=`sed 's/,//g' ip_org.txt` #remove comma
|
sed -i 's/"//g' /tmp/ip_org.tmp #remove double quotes
|
||||||
|
fi
|
||||||
|
org=`sed 's/,//g' /tmp/ip_org.tmp` #remove comma
|
||||||
|
|
||||||
curl --include --request POST --header "Content-Type: application/json" --data-binary "[{
|
curl --include --request POST --header "Content-Type: application/json" --data-binary "[{
|
||||||
\"device_info\" :\"$device_info\",
|
\"device_info\" :\"$device_info\",
|
||||||
|
@ -34,5 +42,3 @@ curl --include --request POST --header "Content-Type: application/json" --data-b
|
||||||
\"city\" :\"$city\",
|
\"city\" :\"$city\",
|
||||||
\"org\" :\"$org\"
|
\"org\" :\"$org\"
|
||||||
}]" $url > /dev/null
|
}]" $url > /dev/null
|
||||||
|
|
||||||
rm ip_*
|
|
||||||
|
|
|
@ -45,9 +45,9 @@ if not exist "%tmpPath%ip_org.tmp" (
|
||||||
powershell -Command "(gc %tmpPath%ip_org.tmp) -replace ',' , '' | Out-File -encoding ASCII %tmpPath%ip_org.tmp"
|
powershell -Command "(gc %tmpPath%ip_org.tmp) -replace ',' , '' | Out-File -encoding ASCII %tmpPath%ip_org.tmp"
|
||||||
)
|
)
|
||||||
|
|
||||||
set country=<%tmpPath%ip_country.tmp
|
set /p country=<%tmpPath%ip_country.tmp
|
||||||
set city=<%tmpPath%ip_city.tmp
|
set /p city=<%tmpPath%ip_city.tmp
|
||||||
set org=<%tmpPath%ip_org.tmp
|
set /p org=<%tmpPath%ip_org.tmp
|
||||||
set raw_data=[{^
|
set raw_data=[{^
|
||||||
\"device_info\" :\"%devie_info%\",^
|
\"device_info\" :\"%devie_info%\",^
|
||||||
\"project_info\" :\"%1\",^
|
\"project_info\" :\"%1\",^
|
||||||
|
|
Loading…
Reference in New Issue