Add opkg.sh containing write_config to write config files withing bash
This commit is contained in:
parent
642a6f5501
commit
701757917a
96
opkg.sh
Executable file
96
opkg.sh
Executable file
@ -0,0 +1,96 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
write_config() {
|
||||||
|
local path="$1"
|
||||||
|
local data="{
|
||||||
|
\"ini\" : {
|
||||||
|
\"/opt/app/sysconfig/ISMASMgr.ini\" : \"d41d8cd98f00b204e9800998ecf8427e\",
|
||||||
|
\"/opt/app/sysconfig/sysconfig.ini\" : \"d41d8cd98f00b204e9800998ecf8427e\",
|
||||||
|
\"/opt/app/sysconfig/SystemControl.ini\" : \"d41d8cd98f00b204e9800998ecf8427e\"
|
||||||
|
},
|
||||||
|
\"conf\" : {
|
||||||
|
\"szeged/1/1/etc/psa_config/emp.conf\" : \"d41d8cd98f00b204e9800998ecf8427e\",
|
||||||
|
\"szeged/1/1/etc/psa_config/printer.conf\": \"d41d8cd98f00b204e9800998ecf8427e\"
|
||||||
|
},
|
||||||
|
\"opkg\" : {"
|
||||||
|
|
||||||
|
local cnt=0
|
||||||
|
for package_name in $(opkg list-installed); # list names of installed packages
|
||||||
|
do
|
||||||
|
if ! grep -q "^[a-zA-Z]" <<< $package_name; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$package_name" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
cnt=$((cnt+1))
|
||||||
|
|
||||||
|
printf "%3d:%s\n" "$cnt" "$package_name"
|
||||||
|
|
||||||
|
# Format of package info:
|
||||||
|
#
|
||||||
|
# Package: openssh-scp
|
||||||
|
# Version: 7.8p1+git-r0
|
||||||
|
# Depends: libc6 (>= 2.28), update-alternatives-opkg
|
||||||
|
# Status: install ok installed
|
||||||
|
# Section: console/network
|
||||||
|
# Architecture: cortexa9t2hf-neon
|
||||||
|
# Maintainer: Poky <poky@yoctoproject.org>
|
||||||
|
# MD5Sum: dfffcbb088cd5f180be5e9ee2ad030fe
|
||||||
|
# Size: 32700
|
||||||
|
# Filename: openssh-scp_7.8p1+git-r0_cortexa9t2hf-neon.ipk
|
||||||
|
# Source: openssh_7.8p1+git.bb
|
||||||
|
# Description: A suite of security-related network....
|
||||||
|
# Installed-Size: 58920
|
||||||
|
# Installed-Time: 1654699615
|
||||||
|
#
|
||||||
|
# process substitution (P.S):
|
||||||
|
# run 'opkg info' synchronously to parent script
|
||||||
|
|
||||||
|
exec {fd}< <(opkg info "$package_name") # open fd readable for P.S.
|
||||||
|
cs_pid=$! # remember pid of P.S.
|
||||||
|
|
||||||
|
while read package_info_line <&$fd; do
|
||||||
|
if [[ $package_info_line == Package* ]]; then
|
||||||
|
package=(${package_info_line// / })
|
||||||
|
package="\"${package[1]}\": {"
|
||||||
|
elif [[ $package_info_line == MD5Sum* ]]; then
|
||||||
|
md5sum=(${package_info_line// / })
|
||||||
|
md5sum="\"${md5sum[0]%?}\": \"${md5sum[1]}\","
|
||||||
|
elif [[ $package_info_line == Filename* ]]; then
|
||||||
|
filename=(${package_info_line// / })
|
||||||
|
filename="\"${filename[0]%?}\": \"${filename[1]}\","
|
||||||
|
elif [[ $package_info_line == Installed-Time* ]]; then
|
||||||
|
installed_time=(${package_info_line// / })
|
||||||
|
installed_time="\"${installed_time[0]%?}\": \"${installed_time[1]}\"
|
||||||
|
},"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exec {fd}>&- # close fd (i.e. process substitution)
|
||||||
|
wait $cs_pid # wait for the subshell to finish
|
||||||
|
|
||||||
|
# use 8 spaces
|
||||||
|
data="$data
|
||||||
|
$package
|
||||||
|
$md5sum
|
||||||
|
$filename
|
||||||
|
$installed_time"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$data" =~ ^.*,$ ]]; then
|
||||||
|
data=${data%?}
|
||||||
|
fi
|
||||||
|
|
||||||
|
data="$data
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
echo "$data" > "$path/test.txt"
|
||||||
|
}
|
||||||
|
|
||||||
|
ddd={ date -d @10000000 +'%Y'; }
|
||||||
|
echo $ddd
|
||||||
|
|
||||||
|
# write_config "/tmp/customer_281/szeged" "test.txt"
|
Loading…
Reference in New Issue
Block a user