# Public key will be checked only if below variable is set
#PUBKEY="/path/to/publickey.pem"
-if [ "$PUBKEY" -a ! -r "$PUBKEY" ]; then
- echo "Public key specified but not readable: $PUBKEY"
- exit 1
-fi
-
-if [ -z "$1" ]; then
- echo "Please specify unitdir(s) as decribed in systemd.generator (1 or 3 arguments)"
- exit 1
-fi
-UNITDIR="$1"
-
MY_NAME=$(basename "$0")
if [ "$MY_NAME" = "isu-system-generator" ]; then
exit 1
fi
+log()
+{
+ echo "$MY_NAME: $*" >&2
+}
+
install_units()
{
local srv_path="$1"
if ! mv "${new_srv_path}.tmp" "${new_srv_path}"; then
mv "${confd}/isu.conf" "${confd}/isu.conf.revert" || :
fi
+ log "Installed $INSTANCE service $srv_path for package $isu_pkg_name"
return 0
}
local isu_pkg_name="$1"
if ! mkdir -p "$RUNDIR/$isu_pkg_name/rootfs"; then
- echo "Unable to create directory to mount $isu_pkg_dir's rootfs - skipping ISU package"
+ log "Unable to create directory to mount $isu_pkg_dir's rootfs - skipping ISU package"
return 1
fi
if [ ! -r "$UNITDIR/$mount_unit" ]; then
if ! test -r "$i"/rootfs.img; then
- echo "Can not access rootfs.img. Skipping $isu_pkg_name"
+ log "Can not access rootfs.img. Skipping $isu_pkg_name"
return 1
fi
What=${PKGDIR}/${isu_pkg_name}/rootfs.img
Where=${RUNDIR}/${isu_pkg_name}/rootfs
EOF
- mkdir -p "$UNITDIR/local-fs.target.wants"
- ln -s "../$mount_unit" "$UNITDIR/local-fs.target.wants/"
+ mkdir -p "$UNITDIR/local-fs.target.wants"
+ ln -s "../$mount_unit" "$UNITDIR/local-fs.target.wants/"
+ log "Installed $UNITDIR/$mount_unit for package $isu_pkg_name"
fi
cksum_path="${cksum_sign_path%.sign}"
if [ "$PUBKEY" ]; then
if ! openssl dgst -sha256 -verify "$PUBKEY" -signature "$cksum_sign_path" "$cksum_path"; then
- echo "Public key verification failed for $cksum_path"
+ log "Public key verification failed for $cksum_path"
return 1
fi
- echo "Public key verification succeeded for $isu_pkg_dir"
+ log "Public key verification succeeded for $isu_pkg_dir"
fi
if [ -s "$cksum_path" ]; then
pushd "$isu_pkg_dir"
if ! sha256sum -c --status "$cksum_path"; then
popd
- echo "Checksum verification failed for $isu_pkg_dir - skipping ISU package"
+ log "Checksum verification failed for $isu_pkg_dir - skipping ISU package"
return 1
fi
popd
else
- echo "Missing or broken checksum file: $cksum_path - skipping ISU package"
+ log "Missing or broken checksum file: $cksum_path - skipping ISU package"
return 1
fi
for srv_path in $(compgen -G "${isu_pkg_dir}/${ISU_SERVICES_DIR}"/*.service); do
if ! test -r "$srv_path"; then
- echo "Service file $srv_path not readable. Skipping"
+ log "Service file $srv_path not readable. Skipping"
continue
fi
for unit_path in $(compgen -G "${isu_pkg_dir}/${ISU_SERVICES_DIR}"/*.mount); do
if ! test -r "$unit_path"; then
- echo "Unit file $unit_path not readable. Skipping"
+ log "Unit file $unit_path not readable. Skipping"
continue
fi
cp -a "$unit_path" "$UNITDIR/"
done
}
-# assume isu packages are extracted
+
+# Entry point
+
+if [ "$PUBKEY" -a ! -r "$PUBKEY" ]; then
+ echo "Public key specified but not readable: $PUBKEY"
+ exit 1
+fi
+
+if [ -z "$1" ]; then
+ echo "Please specify unitdir(s) as decribed in systemd.generator (1 or 3 arguments)"
+ exit 1
+fi
+UNITDIR="$1"
+
for i in "$PKGDIR"/*; do
if ! test -d "$i" -a -r "$i"/isu.cfg; then
- echo "Can not access essential ISU package data. Skipping $PKGDIR"
+ log "Can not access essential ISU package data. Skipping $PKGDIR"
continue
fi