mirror of
https://github.com/EnderIce2/rpc-bridge.git
synced 2025-05-27 15:04:34 +00:00
Modified readme and script
This commit is contained in:
parent
66f3bc53f1
commit
14226489d7
@ -53,8 +53,8 @@ Logs are stored in `C:\windows\logs\bridge.log`.
|
|||||||
|
|
||||||
## macOS
|
## macOS
|
||||||
|
|
||||||
The steps to install are almost the same. The only difference is that if you want the service to work, you will have to use [this script](macos.sh) to install a launch agent that will symlink the `$TMPDIR` to a static path (`/tmp/rpc-bridge/tmpdir`).
|
The steps to install are almost the same. The only difference is that if you want the service to work, you will have to use [this script](build/launchd.sh) to install a launch agent that will symlink the `$TMPDIR` to a static path (`/tmp/rpc-bridge/tmpdir`).
|
||||||
To do so, download it, make it executable (`chmod +x macos.sh`) and run `./macos.sh install`. You can uninstall the agent by running `./macos.sh uninstall`.
|
To do so, download it, make it executable (`chmod +x launchd.sh`) and run `./launchd.sh install`. You can uninstall the agent by running `./launchd.sh uninstall`.
|
||||||
|
|
||||||
## Compiling from source
|
## Compiling from source
|
||||||
|
|
||||||
|
84
build/launchd.sh
Executable file
84
build/launchd.sh
Executable file
@ -0,0 +1,84 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script is used to create a LaunchAgent on MacOS, to support the service functionnality.
|
||||||
|
# Usage: ./launchd.sh (install|remove)
|
||||||
|
|
||||||
|
SYMLINK=/tmp/rpc-bridge/tmpdir
|
||||||
|
LOCATION=~/Library/Application\ Support/rpc-bridge
|
||||||
|
SCRIPT=$LOCATION/rpc-bridge
|
||||||
|
AGENT=~/Library/LaunchAgents/com.enderice2.rpc-bridge.plist
|
||||||
|
|
||||||
|
function install() {
|
||||||
|
# Directories
|
||||||
|
if [ ! -d "$SYMLINK" ]; then
|
||||||
|
mkdir -p "$SYMLINK"
|
||||||
|
fi
|
||||||
|
if [ ! -d "$LOCATION" ]; then
|
||||||
|
mkdir -p "$LOCATION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Link script
|
||||||
|
if [ -f "$SCRIPT" ]; then
|
||||||
|
rm -f "$SCRIPT"
|
||||||
|
fi
|
||||||
|
echo "#!/bin/bash
|
||||||
|
TARGET_DIR=/tmp/rpc-bridge/tmpdir
|
||||||
|
if [ ! -d "\$TARGET_DIR" ]; then
|
||||||
|
mkdir -p "\$TARGET_DIR"
|
||||||
|
fi
|
||||||
|
rm -rf "\$TARGET_DIR"
|
||||||
|
ln -s "\$TMPDIR" "\$TARGET_DIR"" > "$SCRIPT"
|
||||||
|
chmod +x "$SCRIPT"
|
||||||
|
|
||||||
|
# LaunchAgent
|
||||||
|
if [ -f "$AGENT" ]; then
|
||||||
|
rm -f "$AGENT"
|
||||||
|
fi
|
||||||
|
echo "<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST File Format//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>com.enderice2.rpc-bridge</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>$SCRIPT</string>
|
||||||
|
</array>
|
||||||
|
<key>RunAtLoad</key>
|
||||||
|
<true />
|
||||||
|
</dict>
|
||||||
|
</plist>" > "$AGENT"
|
||||||
|
launchctl load "$AGENT"
|
||||||
|
echo "LaunchAgent has been installed."
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove() {
|
||||||
|
rm -rf "$SYMLINK"
|
||||||
|
rm -rf "$LOCATION"
|
||||||
|
rm -f "$SCRIPT"
|
||||||
|
if [ -f "$AGENT" ]; then
|
||||||
|
launchctl unload "$AGENT"
|
||||||
|
fi
|
||||||
|
rm -f "$AGENT"
|
||||||
|
echo "LaunchAgent has been removed."
|
||||||
|
}
|
||||||
|
|
||||||
|
# CLI
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "Usage: $0 (install|remove)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
install)
|
||||||
|
install
|
||||||
|
;;
|
||||||
|
remove)
|
||||||
|
remove
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid argument. Please use 'install' or 'remove'."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
88
macos.sh
88
macos.sh
@ -1,88 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Define target directory
|
|
||||||
TARGET_DIR=/tmp/rpc-bridge/tmpdir
|
|
||||||
P_DIR=$(dirname "$TARGET_DIR")
|
|
||||||
FILE_PATH=$P_DIR/link
|
|
||||||
|
|
||||||
# Function to create the symlink and launch agent
|
|
||||||
function install_link() {
|
|
||||||
|
|
||||||
if [ ! -d "$P_DIR" ]; then
|
|
||||||
mkdir -p "$P_DIR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat << EOF > "$FILE_PATH"
|
|
||||||
#!/bin/bash
|
|
||||||
TARGET_DIR=/tmp/rpc-bridge/tmpdir
|
|
||||||
if [ ! -d "\$TARGET_DIR" ]; then
|
|
||||||
mkdir -p "\$TARGET_DIR"
|
|
||||||
fi
|
|
||||||
rm -rf "\$TARGET_DIR"
|
|
||||||
ln -s "\$TMPDIR" "\$TARGET_DIR"
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod +x "$FILE_PATH"
|
|
||||||
|
|
||||||
# Launch agent plist file path
|
|
||||||
PLIST_FILE=~/Library/LaunchAgents/com.rpc-bridge.tmp-symlink.plist
|
|
||||||
|
|
||||||
# Create the launch agent plist with escaped variable
|
|
||||||
cat << EOF > "$PLIST_FILE"
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST File Format//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>Label</key>
|
|
||||||
<string>com.rpc-bridge.tmp-symlink</string>
|
|
||||||
<key>ProgramArguments</key>
|
|
||||||
<array>
|
|
||||||
<string>$FILE_PATH</string>
|
|
||||||
</array>
|
|
||||||
<key>RunAtLoad</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Load the launch agent
|
|
||||||
launchctl load "$PLIST_FILE"
|
|
||||||
echo "Symlink created and launch agent installed."
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to remove the symlink and launch agent (unchanged)
|
|
||||||
function remove_link() {
|
|
||||||
# Remove the symlink
|
|
||||||
rm -rf "$TARGET_DIR"
|
|
||||||
|
|
||||||
# Launch agent plist file path
|
|
||||||
PLIST_FILE=~/Library/LaunchAgents/com.rpc-bridge.tmp-symlink.plist
|
|
||||||
|
|
||||||
# Unload the launch agent
|
|
||||||
launchctl unload "$PLIST_FILE"
|
|
||||||
|
|
||||||
# Remove the files
|
|
||||||
rm -f "$PLIST_FILE"
|
|
||||||
rm -f "$FILE_PATH"
|
|
||||||
echo "Symlink removed and launch agent uninstalled."
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check for user input
|
|
||||||
if [ $# -eq 0 ]; then
|
|
||||||
echo "Usage: $0 (install|remove)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Action based on user input
|
|
||||||
case $1 in
|
|
||||||
install)
|
|
||||||
install_link
|
|
||||||
;;
|
|
||||||
remove)
|
|
||||||
remove_link
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Invalid argument. Please use 'install' or 'remove'."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
Loading…
x
Reference in New Issue
Block a user