test shell
parent
c7dda61adf
commit
d44ef061da
@ -0,0 +1,79 @@
|
||||
#!/bin/zsh
|
||||
|
||||
home=/home/syui
|
||||
name=arch
|
||||
a=$home/$name
|
||||
|
||||
function arch_in(){
|
||||
mkdir -p $a
|
||||
sudo pacstrap -c $a base
|
||||
#sudo echo pts/0 >> $a/etc/securetty
|
||||
#sudo echo pts/1 >> $a/etc/securetty
|
||||
sudo rm -rf /var/lib/machines/$name
|
||||
sudo rm -rf /var/lib/machines/${name}back
|
||||
sudo mv $a /var/lib/machines/
|
||||
sudo machinectl clone arch archback
|
||||
}
|
||||
|
||||
function arch_rm(){
|
||||
sudo machinectl remove $name
|
||||
}
|
||||
|
||||
function arch_up(){
|
||||
sudo machinectl poweroff $name > /dev/null 2>&1
|
||||
sleep 5
|
||||
sudo machinectl terminate $name > /dev/null 2>&1
|
||||
sleep 5
|
||||
sudo machinectl start ${name}back
|
||||
sleep 5
|
||||
ssh ${name}back pacman -Syu --noconfirm
|
||||
sleep 5
|
||||
sudo machinectl poweroff ${name}back
|
||||
}
|
||||
|
||||
function arch_st(){
|
||||
sudo machinectl start $name
|
||||
}
|
||||
|
||||
function arch_of(){
|
||||
sudo machinectl poweroff $name
|
||||
}
|
||||
|
||||
function arch_ex(){
|
||||
sudo machinectl shell $name
|
||||
$1
|
||||
poweroff
|
||||
}
|
||||
|
||||
function arch_re(){
|
||||
sudo machinectl poweroff $name > /dev/null 2>&1
|
||||
sleep 5
|
||||
sudo machinectl terminate $name > /dev/null 2>&1
|
||||
sleep 5
|
||||
sudo machinectl remove $name
|
||||
sleep 5
|
||||
sudo machinectl clone ${name}back $name
|
||||
sleep 5
|
||||
sudo machinectl start $name
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"update"|"-u")
|
||||
arch_up
|
||||
arch_re
|
||||
echo "machinectl update done"
|
||||
;;
|
||||
"reset"|"-r")
|
||||
arch_re
|
||||
echo "machinectl reset done"
|
||||
;;
|
||||
*)
|
||||
sudo machinectl start $name
|
||||
t=`ssh $name "$*"`
|
||||
if [ -z "$t" ];then
|
||||
ssh -tt $name "$*"
|
||||
else
|
||||
echo "$t"
|
||||
fi
|
||||
;;
|
||||
esac
|
@ -0,0 +1,40 @@
|
||||
#!/bin/zsh
|
||||
|
||||
dir=${0:a:h}
|
||||
f=$dir/diffusion_prompt.txt
|
||||
|
||||
seed=$RANDOM
|
||||
|
||||
sd_prompt_a="masterpiece, high quality, very_high_resolution, large_filesize, full color"
|
||||
|
||||
## kawaii girl random prompt
|
||||
# ra=$(($RANDOM % 2 + 1))
|
||||
# rp="beautiful kawaii "`echo "little girl,girl"|cut -d , -f $ra|tr -d ,`
|
||||
# rb=$(($RANDOM % 3 + 1))
|
||||
# rbp="with "`echo "gold,silver,black"|cut -d , -f $rb|tr -d ,`" hair"
|
||||
# rc=$(($RANDOM % 4 + 1))
|
||||
# rcp=`echo "wavy,long,straight,"|cut -d , -f $rc|tr -d ,`
|
||||
# rd=$(($RANDOM % 3 + 1))
|
||||
# rdp="in "`echo "fluttery white onepice,simple white onepice,normal white school uniform"|cut -d , -f $rd|tr -d ,`
|
||||
# echo $sd_prompt_a, $rp $rdp $rcp $rbp
|
||||
|
||||
if [ -n "$1" ];then
|
||||
echo $sd_prompt_a $* >! $f
|
||||
cat $f
|
||||
q=`cat $f`
|
||||
else
|
||||
echo no query
|
||||
exit
|
||||
fi
|
||||
|
||||
rm -rf $dir/png
|
||||
mkdir -p $dir/png
|
||||
ssh win Remove-Item -Recurse -Force stable-diffusion/outputs
|
||||
ssh win Remove-Item -Recurse -Force msbot
|
||||
ssh win mkdir stable-diffusion/outputs
|
||||
ssh win mkdir msbot
|
||||
ssh win "conda activate ldm;cd ./stable-diffusion/;python optimizedSD/optimized_txt2img.py --prompt \"${q}\" --H 512 --W 512 --seed $seed --n_iter 1 --n_samples 1 --ddim_steps 50"
|
||||
diff_dir=`ssh win ls stable-diffusion/outputs/txt2img-samples -Name|cut -b 1-2`
|
||||
ssh win "cd stable-diffusion/outputs/txt2img-samples;mv $diff_dir* $diff_dir -Force;mv $diff_dir/*.png ~/msbot/t.png -Force"
|
||||
ssh win ".\scoop\apps\imagemagick\current\convert.exe msbot/t.png msbot/t.jpg"
|
||||
scp -r win:msbot/t.jpg $dir/png/t.jpg
|
@ -0,0 +1,85 @@
|
||||
extern crate reqwest;
|
||||
use crate::token_toml;
|
||||
use crate::url;
|
||||
use serde_json::json;
|
||||
use iso8601_timestamp::Timestamp;
|
||||
|
||||
pub async fn post_request(text: String, cid: String, uri: String, mid: String, itype: String) -> String {
|
||||
|
||||
let token = token_toml(&"access");
|
||||
let did = token_toml(&"did");
|
||||
|
||||
let url = url(&"record_create");
|
||||
//let url = "https://bsky.social/xrpc/com.atproto.repo.createRecord";
|
||||
let col = "app.bsky.feed.post".to_string();
|
||||
|
||||
let d = Timestamp::now_utc();
|
||||
let d = d.to_string();
|
||||
|
||||
//{
|
||||
// "did": "",
|
||||
// "collection": "",
|
||||
// "record": {
|
||||
// "text": "",
|
||||
// "createdAt": "",
|
||||
// "": "",
|
||||
// "embed": {
|
||||
// "$type": "app.bsky.embed.images",
|
||||
// "images": [
|
||||
// {
|
||||
// "image": {
|
||||
// "cid": "",
|
||||
// "mimeType": ""
|
||||
// },
|
||||
// "alt": ""
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
let post = Some(json!({
|
||||
"did": did.to_string(),
|
||||
"collection": col.to_string(),
|
||||
"record": {
|
||||
"text": text.to_string(),
|
||||
"createdAt": d.to_string(),
|
||||
"embed": {
|
||||
"$type": "app.bsky.embed.images",
|
||||
"images": [
|
||||
{
|
||||
"image": {
|
||||
"cid": mid.to_string(),
|
||||
"mimeType": itype.to_string()
|
||||
},
|
||||
"alt": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"reply": {
|
||||
"root": {
|
||||
"cid": cid.to_string(),
|
||||
"uri": uri.to_string()
|
||||
},
|
||||
"parent": {
|
||||
"cid": cid.to_string(),
|
||||
"uri": uri.to_string()
|
||||
}
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let res = client
|
||||
.post(url)
|
||||
.json(&post)
|
||||
.header("Authorization", "Bearer ".to_owned() + &token)
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
return res
|
||||
}
|
Loading…
Reference in New Issue