To set up Shadowrocket and run a script,follow these organized steps:

  1. Install npm: Open your terminal and type npm install, which will install the Node Package Manager.

  2. Create the shadowrocket directory: Use mkdir shadowrocket to create the necessary directory.

  3. Create the config.json file: Use npm create with the configuration data. For example:

    npm create config.json

    This will create a JSON file named config.json in the shadowrocket directory.

  4. Create the run.sh script: Write a bash script in the shadowrocket/run.sh file. It should look something like this:

    #!/bin/bash
    echo "Starting run script..."
    rm -f "$(echo 'shadowrocket/ $1' | cut -d/ -f2)"
    echo "Scripting: /bin/bash"
    echo "Starting at: $1"
    echo "Please enter the script name:"
    echo "1: web"
    echo "2: command-line"
    read script_name= $(echo 'web' | cut -d/ -f2)
    if [ $script_name = 1 ]; then
      echo "Starting a web server..."
      cd /bin
      export PATH=/bin
      npm run dev:web
    else
      echo "Starting a command-line script..."
      cd /bin
      npm run start
    fi

    This script will start a web server or a command-line application based on the script name.

  5. Run the script in the background: Use the background command to execute the script:

    background -f run.sh

    This will run the script in the shadowrocket/run.sh file in the background.

  6. Handle errors: Shadowrocket typically stops execution if an error occurs. To capture output, use the logger:

    logger.add

    You can also check the error message if it appears.

  7. Organize applications: Consider creating subdirectories for different types of applications, such as web for web apps and command-line for command-line tools, to keep things organized.

  8. Permissions: Ensure the shadowrocket directory has write permissions. Use a virtual environment with Node.js and install npm.

By following these steps, you can set up Shadowrocket and run a script to execute in the background.

To set up Shadowrocket and run a script,follow these organized steps:

扫码添加高速VPN梯子官方微信

扫码添加高速VPN梯子官方微信

0592-571-8643
扫码添加高速VPN梯子官方微信

扫码添加高速VPN梯子官方微信

网站地图