mirror of
https://github.com/morgant/basiliskiivm.git
synced 2024-09-27 16:55:40 +00:00
Track the PID in the .BasiliskIIVM package.
This commit is contained in:
parent
6ed31e8386
commit
7816a05e9a
20
basiliskiivm
20
basiliskiivm
@ -21,14 +21,9 @@ version="0.1"
|
|||||||
copyright="Copyright (c) 2016 Morgan Aldridge"
|
copyright="Copyright (c) 2016 Morgan Aldridge"
|
||||||
|
|
||||||
# global variables
|
# global variables
|
||||||
user="$(whoami)"
|
|
||||||
BASILISKII_BINARY="${BASILISKII_BINARY:=BasiliskII}"
|
BASILISKII_BINARY="${BASILISKII_BINARY:=BasiliskII}"
|
||||||
if [ "$user" == "root" ]; then
|
|
||||||
PID_FILE_PATH="${PID_FILE_PATH:="/var/run/${tool}"}"
|
|
||||||
else
|
|
||||||
PID_FILE_PATH="${PID_FILE_PATH:="${HOME}/.${tool}"}"
|
|
||||||
fi
|
|
||||||
basiliskii_prefs_file=".basilisk_ii_prefs"
|
basiliskii_prefs_file=".basilisk_ii_prefs"
|
||||||
|
basiliskii_pid_file=".basiliskii.pid"
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo "Usage: ${tool} [options] <command>"
|
echo "Usage: ${tool} [options] <command>"
|
||||||
@ -67,7 +62,7 @@ function vm_pkg_config_file() {
|
|||||||
|
|
||||||
local vm="$(vm_pkg_name "$1")"
|
local vm="$(vm_pkg_name "$1")"
|
||||||
if [ -n "$vm" ]; then
|
if [ -n "$vm" ]; then
|
||||||
local prefs_file="$1/${basiliskii_prefs_file}"
|
local prefs_file="${1}/${basiliskii_prefs_file}"
|
||||||
if [ -f "$prefs_file" ]; then
|
if [ -f "$prefs_file" ]; then
|
||||||
echo "$prefs_file"
|
echo "$prefs_file"
|
||||||
sucess=true
|
sucess=true
|
||||||
@ -82,7 +77,7 @@ function vm_is_running() {
|
|||||||
|
|
||||||
local vm="$(vm_pkg_name "$1")"
|
local vm="$(vm_pkg_name "$1")"
|
||||||
if [ -n "$vm" ]; then
|
if [ -n "$vm" ]; then
|
||||||
local pid_path="${PID_FILE_PATH}/${vm}.pid"
|
local pid_path="${1}/${basiliskii_pid_file}"
|
||||||
if [ -f "$pid_path" ]; then
|
if [ -f "$pid_path" ]; then
|
||||||
if ps -p "$(cat "$pid_path")" > /dev/null 2>&1; then
|
if ps -p "$(cat "$pid_path")" > /dev/null 2>&1; then
|
||||||
running=true
|
running=true
|
||||||
@ -98,12 +93,7 @@ function vm_create_pid_file() {
|
|||||||
|
|
||||||
local vm="$(vm_pkg_name "$1")"
|
local vm="$(vm_pkg_name "$1")"
|
||||||
if [ -n "$vm" ]; then
|
if [ -n "$vm" ]; then
|
||||||
local pid_path="${PID_FILE_PATH}/${vm}.pid"
|
local pid_path="${1}/${basiliskii_pid_file}"
|
||||||
|
|
||||||
# create the pid file directory, if necessary
|
|
||||||
if [ ! -d "$PID_FILE_PATH" ]; then
|
|
||||||
mkdir "${PID_FILE_PATH}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# create the pid file
|
# create the pid file
|
||||||
if ! echo "$2" > "$pid_path"; then
|
if ! echo "$2" > "$pid_path"; then
|
||||||
@ -121,7 +111,7 @@ function vm_delete_pid_file() {
|
|||||||
|
|
||||||
local vm="$(vm_pkg_name "$1")"
|
local vm="$(vm_pkg_name "$1")"
|
||||||
if [ -n "$vm" ]; then
|
if [ -n "$vm" ]; then
|
||||||
local pid_path="${PID_FILE_PATH}/${vm}.pid"
|
local pid_path="${1}/${basiliskii_pid_file}"
|
||||||
|
|
||||||
if [ ! -f "$pid_path" ]; then
|
if [ ! -f "$pid_path" ]; then
|
||||||
echo "ERROR! The '$vm' BasiliskII VM PID file '$pid_path' doesn't exist, so cannot delete it."
|
echo "ERROR! The '$vm' BasiliskII VM PID file '$pid_path' doesn't exist, so cannot delete it."
|
||||||
|
Loading…
Reference in New Issue
Block a user