Microsoft SQL Server OpenRC Script
Hello, i just want to share my mssql-server init script for openrc, it seems it doesnt have any existing script for it, so i hope this helps
#!/sbin/openrc-run
name="mssql-server"
sql_server_bin="/opt/mssql/bin/sqlservr"
sql_data_dir="/var/opt/mssql/data"
sql_server_options=""
command_user="mssql"
command_group="mssql"
depend() {
use logger net
}
start_pre() {
checkpath -d -m 750 -o "${command_user}:${command_group}" "${sql_data_dir}"
}
start() {
ebegin "Starting ${name}"
start-stop-daemon --start --background \
--user "${command_user}:${command_group}" \
--exec "${sql_server_bin}" \
-- ${sql_server_options}
eend $?
}
stop() {
ebegin "Stopping ${name}"
start-stop-daemon --stop --quiet --exec "${sql_server_bin}"
eend $?
}
restart() {
ebegin "Restarting ${name}"
svc_stop
sleep 1
svc_start
eend $?
}
Create the script and save it as mssql-server, move it to /etc/init.d, make sure it can be executed and run
sudo rc-update add mssql-server default
sudo rc-service mssql-server start