在开头运行init.d脚本 [英] Run an init.d script at the beginning

查看:119
本文介绍了在开头运行init.d脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ubuntu中的 /etc/init.d/skelton 脚本创建了一个init.d脚本来运行我的C ++守护程序。并使用 update-rc.d myservice defaults 99 命令安装新脚本,使其工作正常。现在我想创建另外两个需要在启动开始时运行的shell scrits并执行一些命令并在最后重启(因为它会在第一次启动时节省更多时间)





我想在新的init.d脚本首次启动时执行这个脚本



 SETTINGSDIRPATH =/ etc / Accutrac
PARTITIONEXPAND =/ PartitionExpand
PARTITIONVAL = $ SETTINGSDIRPATH $ PARTITIONEXPAND

if [! -d$ SETTINGSDIRPATH];那么

mkdir -p$ SETTINGSDIRPATH

fi

如果[! -f $ PARTITIONVAL];那么

echo 0> $ PARTITIONVAL
fi

PARTEXPANDED = $(<$ PARTITIONVAL)

if [$ PARTEXPANDED==0];然后#expand root partition if if status flag = 0

/boot/raspi-expand-rootfs.sh #script tp expand root partition
echo 1> $ PARTITIONVAL#change status flag = 1
shutdown -r now #restart系统使更改影响
fi







在启动其他脚本之前,制作一个将在启动开始时运行此脚本的新脚本所需的步骤。





建立以太网连接并分配IP地址后,我的另一个init.d脚本需要在引导的最后一步运行

解决方案

< blockquote> SETTINGSDIRPATH


PARTITIONEXPAND

if [! -d


SETTINGSDIRPATH];然后

mkdir -p


I created one init.d script to run my C++ daemon using /etc/init.d/skelton script from ubuntu. and installed the new script using "update-rc.d myservice defaults 99" command its working perfectly. Now I want to create two more shell scrits one needs to run at the beginning of the boot as possible and to execute some commands and restart at the end(because it will save much more time at the first boot)


I want to execute this script at the beginning of first boot from a new init.d script

SETTINGSDIRPATH="/etc/Accutrac"
PARTITIONEXPAND="/PartitionExpand"
PARTITIONVAL=$SETTINGSDIRPATH$PARTITIONEXPAND

if [ ! -d "$SETTINGSDIRPATH" ]; then

   mkdir -p "$SETTINGSDIRPATH"
	
fi

if [ ! -f $PARTITIONVAL ]; then

		echo 0 > "$PARTITIONVAL"
	fi

PARTEXPANDED=$(<"$PARTITIONVAL")

if [ "$PARTEXPANDED" == "0" ]; then #expand root partition if status flag=0

	/boot/raspi-expand-rootfs.sh      #script tp expand root partition	
	echo 1 > "$PARTITIONVAL"      	#change status flag=1
	shutdown -r now 		#restart system to make the changes affect 
fi  




what are the steps needed to make a new script that will run this script at the beginning of boot before starting other scripts.


My another init.d script needs to run at the last step of boot after establishing Ethernet connection and assigning an IP address

解决方案

SETTINGSDIRPATH


PARTITIONEXPAND if [ ! -d "


SETTINGSDIRPATH" ]; then mkdir -p "


这篇关于在开头运行init.d脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆