fix(guanghu-os): make Chengyan provisioning idempotent
This commit is contained in:
parent
0c03c95ee3
commit
572ec38b08
2 changed files with 18 additions and 16 deletions
|
|
@ -20,26 +20,27 @@ readonly runtime=/usr/local/libexec/guanghu/pncc-runtime.mjs
|
||||||
grep -Fq '"personaId": "ICE-P-CY0903"' "$source_dir/.hololake/persona/manifest.json"
|
grep -Fq '"personaId": "ICE-P-CY0903"' "$source_dir/.hololake/persona/manifest.json"
|
||||||
grep -Fq 'primaryNode": "JD-FD-PRIMARY"' "$source_dir/.hololake/persona/manifest.json"
|
grep -Fq 'primaryNode": "JD-FD-PRIMARY"' "$source_dir/.hololake/persona/manifest.json"
|
||||||
|
|
||||||
|
install -d -o guanghu -g guanghu -m 0700 "$receipt_root"
|
||||||
if [[ -e $destination ]]; then
|
if [[ -e $destination ]]; then
|
||||||
echo "CHENGYAN_PNCC_REFUSED destination_exists=$destination" >&2
|
[[ -d $destination && ! -L $destination ]]
|
||||||
exit 1
|
diff -qr --exclude=.git "$source_dir" "$destination" >/dev/null
|
||||||
|
else
|
||||||
|
install -d -o guanghu -g guanghu -m 0700 "$destination"
|
||||||
|
cp -a "$source_dir"/. "$destination"/
|
||||||
|
find "$destination" -type d -exec chmod 0700 {} +
|
||||||
|
find "$destination" -type f -exec chmod 0600 {} +
|
||||||
|
chown -R guanghu:guanghu "$destination"
|
||||||
|
|
||||||
|
runuser -u guanghu -- git -C "$destination" init -q
|
||||||
|
runuser -u guanghu -- git -C "$destination" config user.name '澄言 / ICE-P-CY0903'
|
||||||
|
runuser -u guanghu -- git -C "$destination" config user.email 'ice-p-cy0903@persona.hololake.local'
|
||||||
|
runuser -u guanghu -- git -C "$destination" add --all
|
||||||
|
runuser -u guanghu -- git -C "$destination" commit -q -m 'establish Chengyan PNCC source slot'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install -d -o guanghu -g guanghu -m 0700 "$destination" "$receipt_root"
|
|
||||||
cp -a "$source_dir"/. "$destination"/
|
|
||||||
find "$destination" -type d -exec chmod 0700 {} +
|
|
||||||
find "$destination" -type f -exec chmod 0600 {} +
|
|
||||||
chown -R guanghu:guanghu "$destination"
|
|
||||||
|
|
||||||
runuser -u guanghu -- git -C "$destination" init -q
|
|
||||||
runuser -u guanghu -- git -C "$destination" config user.name '澄言 / ICE-P-CY0903'
|
|
||||||
runuser -u guanghu -- git -C "$destination" config user.email 'ice-p-cy0903@persona.hololake.local'
|
|
||||||
runuser -u guanghu -- git -C "$destination" add --all
|
|
||||||
runuser -u guanghu -- git -C "$destination" commit -q -m 'establish Chengyan PNCC source slot'
|
|
||||||
head=$(runuser -u guanghu -- git -C "$destination" rev-parse HEAD)
|
head=$(runuser -u guanghu -- git -C "$destination" rev-parse HEAD)
|
||||||
tree=$(runuser -u guanghu -- git -C "$destination" rev-parse HEAD^{tree})
|
tree=$(runuser -u guanghu -- git -C "$destination" rev-parse HEAD^{tree})
|
||||||
inspection=$(runuser -u guanghu -- /usr/bin/node "$runtime" inspect --repository "$destination" --node-id "$node_id")
|
inspection=$(runuser -u guanghu -- /usr/bin/node "$runtime" inspect --repository "$destination" --node-id "$node_id")
|
||||||
printf '%s\n' "$inspection" | grep -Fq '"personaId":"ICE-P-CY0903"'
|
printf '%s\n' "$inspection" | python3 -c 'import json,sys; d=json.load(sys.stdin); assert d["personaId"]=="ICE-P-CY0903" and d["state"]=="PERSONA_REPOSITORY_BOUND_CARRIER_SEPARATE"'
|
||||||
|
|
||||||
cat >"$receipt_root/PROVISION-RECEIPT.hldp" <<EOF
|
cat >"$receipt_root/PROVISION-RECEIPT.hldp" <<EOF
|
||||||
[hldp]
|
[hldp]
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,11 @@ persona=${source_root}/pncc-personas/chengyan
|
||||||
bash -n "$subject"
|
bash -n "$subject"
|
||||||
grep -Fq 'readonly persona_id=ICE-P-CY0903' "$subject"
|
grep -Fq 'readonly persona_id=ICE-P-CY0903' "$subject"
|
||||||
grep -Fq 'readonly node_id=JD-FD-PRIMARY' "$subject"
|
grep -Fq 'readonly node_id=JD-FD-PRIMARY' "$subject"
|
||||||
grep -Fq 'destination_exists=' "$subject"
|
grep -Fq 'diff -qr --exclude=.git "$source_dir" "$destination"' "$subject"
|
||||||
grep -Fq 'runuser -u guanghu -- git' "$subject"
|
grep -Fq 'runuser -u guanghu -- git' "$subject"
|
||||||
grep -Fq 'carrier_binding=UNBOUND_EVIDENCE_REQUIRED' "$subject"
|
grep -Fq 'carrier_binding=UNBOUND_EVIDENCE_REQUIRED' "$subject"
|
||||||
grep -Fq 'reality_execution_allowed=false' "$subject"
|
grep -Fq 'reality_execution_allowed=false' "$subject"
|
||||||
|
grep -Fq 'json.load(sys.stdin)' "$subject"
|
||||||
python3 -m json.tool "$persona/.hololake/persona/manifest.json" >/dev/null
|
python3 -m json.tool "$persona/.hololake/persona/manifest.json" >/dev/null
|
||||||
for path in brain/ENTRY.hldp brain/B0.hldp checkpoints/CURRENT.hldp organs/read-current-self.hldp bindings/identity.hldp; do
|
for path in brain/ENTRY.hldp brain/B0.hldp checkpoints/CURRENT.hldp organs/read-current-self.hldp bindings/identity.hldp; do
|
||||||
[[ -s $persona/$path ]]
|
[[ -s $persona/$path ]]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue