Need to add custom script as service in init.rc for Android 10 I am trying run shell script in device boot-up time.
Steps:

Created shell script and placed into /system/bin/usbmountd.sh

Added test.sh in inir.rc.
service usbmountd /system/bin/usbmountd.sh
user system
disabled
oneshot


Add a new Domain “usbmountd.te” in the location of device/broadcom/XXX/sepolicy/treble/ usbmountd.te
 type usbmountd, domain;
 type usbmountd_exec, exec_type, file_type;
 init_daemon_domain(usbmountd)


Add the Label &quot;/system/bin/usbmountd.sh&quot; to device/broadcom/XXX/sepolicy/treble/file_contexts
 /system/bin/usbmountd     u:object_r: _exec:s0


Added in device/broadcom/xxx/sepolicy/xxx/file.te
 type usbmountd_exec, system_file_type, file_type;



Error:
[ 81% 747/921] build out/target/product/xxx/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows
FAILED: out/target/product/xxx/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows
/bin/bash -c &quot;(ASAN_OPTIONS=detect_leaks=0 out/host/linux-x86/bin/checkpolicy -M -c             30 -o out/target/product/xxx/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows.tmp out/target/product/xxx/obj/ETC/sepolicy_neverallows_intermediates/policy.conf ) &amp;&amp; (out/host/linux-x86/bin/sepolicy-analyze out/target/product/xxx/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows.tmp neverallow -w -f out/target/product/xxx/obj/ETC/sepolicy_neverallows_intermediates/policy_2.conf ||           ( echo \&quot;\&quot; 1&gt;&amp;2;         echo \&quot;sepolicy-analyze failed. This is most likely due to the use\&quot; 1&gt;&amp;2;            echo \&quot;of an expanded attribute in a neverallow assertion. Please fix\&quot; 1&gt;&amp;2;           echo \&quot;the policy.\&quot; 1&gt;&amp;2;            exit 1 ) ) &amp;&amp; (touch out/target/product/xxx/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows.tmp ) &amp;&amp; (mv out/target/product/xxx/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows.tmp out/target/product/xxx/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows )&quot;
device/xxx/xxx/sepolicy/treble/usbmountd.te:3:ERROR 'Duplicate declaration of type' at token ';' on line 60116:
type usbmountd_exec, exec_type, file_type;
type usbmountd, domain;
checkpolicy:  error(s) encountered while parsing configuration
The error is 'Duplicate declaration of type'
The problem is step 5 in which you declare
type usbmountd_exec, system_file_type, file_type;
You already declared that same type usbmountd_exec in step 3. So remove the duplicate declaration.
Also in step 4 it should look like this:
/system/bin/usbmountd.sh     u:object_r:usbmountd_exec:s0