Hi,
I did a user build for aosp9 so will not have su binaries for build, I want to run this shell file:
#!/usr/bin/env bash
# Add the IP address to the eth0 interface
ip addr add 192.168.43.0/24 dev eth0
# Check if the command was successful
if [ $? -eq 0 ]; then
echo "IP address added successfully."
else
echo "Failed to add IP address."
fi
I want to run this shell file with help of a service wtih root permissions to make that command work so here is my init.staticaddr.rc:
# Set up the ethernet ipv4 addr
service staticaddr /vendor/bin/sh /vendor/etc/staticcommand.sh
class core
user root
group root
oneshot
I wrote .te file for this service like this and added in sepolicy folder:
type staticaddr, domain;
type staticaddr_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(staticaddr)
In file context i added this line:
# static ip
/vendor/bin/staticaddr u:object_r:staticaddr_exec:s0
in device.mk files I have added product copy files to copy these init.staticaddr.rc file to root/ folder and staticaddr.sh file to system/etc/folder
Build is successful, but there is not output traces of that shell file running i.e, static ip is not getting assigned to ethernet, same procedure is working fine for user debug build which will have root access, when i did adb shell service list, I cannot see the service name and also ehternet ip is not getting updated.
can anyone please guide where I am doing wrong