diff --git a/leads_vec/_bootloader/leads_vec.service.sh b/leads_vec/_bootloader/leads_vec.service.sh index 50972d9c..088fdd61 100644 --- a/leads_vec/_bootloader/leads_vec.service.sh +++ b/leads_vec/_bootloader/leads_vec.service.sh @@ -1,11 +1,11 @@ #!/bin/bash -if [ ! -x "/usr/local/leads/config.json" ]; +if [ ! -r "/usr/local/leads/config.json" ] then echo "Error: Config file does not exist" exit 1 fi -while ! xhost >& /dev/null; +while ! xhost >& /dev/null do sleep 1 done # change the interpreter or adjust the arguments according to your needs diff --git a/leads_vec/_bootloader/systemd.py b/leads_vec/_bootloader/systemd.py index 65209d14..c703583e 100644 --- a/leads_vec/_bootloader/systemd.py +++ b/leads_vec/_bootloader/systemd.py @@ -15,8 +15,8 @@ def create_service() -> None: _mkdir("/usr/local/leads") with open("/usr/local/leads/config.json", "w") as f: f.write(str(_Config({}))) - _chmod("/usr/local/leads/config.json", 777) - _chmod(script := f"{_abspath(__file__)[:-10]}leads_vec.service.sh", 777) + _chmod("/usr/local/leads/config.json", 0x644) + _chmod(script := f"{_abspath(__file__)[:-10]}leads_vec.service.sh", 0o755) with open("/etc/systemd/system/leads_vec.service", "w") as f: f.write( "[Unit]\n" diff --git a/scripts/frp-config.sh b/scripts/frp-config.sh index e39a8d31..80437a37 100644 --- a/scripts/frp-config.sh +++ b/scripts/frp-config.sh @@ -5,15 +5,15 @@ abort() { exit 1 } -if [ "${EUID:-$(id -u)}" -ne 0 ]; +if [ "${EUID:-$(id -u)}" -ne 0 ] then abort "Error: This script requires root permission" fi -if ! test -d "/usr/local/frp"; +if ! test -d "/usr/local/frp" then abort "Error: /usr/local/frp not found" fi execute() { - if ! "$@"; + if ! "$@" then abort "$(printf "Failed: %s" "$@")" fi } @@ -23,14 +23,14 @@ execute_root() { } require_argument() { - if [ -n "$1" ]; + if [ -n "$1" ] then echo "$1" else abort "Required argument $2 does not exist" fi } argument_exists_or() { - if [ -n "$1" ]; + if [ -n "$1" ] then echo "$1" else echo "$2" fi diff --git a/scripts/frp-install.sh b/scripts/frp-install.sh index 2c5b6b25..24ad807c 100644 --- a/scripts/frp-install.sh +++ b/scripts/frp-install.sh @@ -5,16 +5,16 @@ abort() { exit 1 } -if [ "${EUID:-$(id -u)}" -ne 0 ]; +if [ "${EUID:-$(id -u)}" -ne 0 ] then abort "Error: This script requires root permission" fi -if test -d "/usr/local/frp"; +if test -d "/usr/local/frp" then abort "Error: /usr/local/frp already exists" fi execute() { - if ! "$@"; + if ! "$@" then abort "$(printf "Failed: %s" "$@")" fi } @@ -23,13 +23,13 @@ execute_root() { execute "sudo" "$@" } -if ! command -v curl > /dev/null; +if ! command -v curl > /dev/null then echo "cURL is not available, installing..." execute_root "apt" "install" "-y" "curl" fi latest_release=$(curl -s "https://api.github.com/repos/fatedier/frp/releases/latest" | grep -o '"tag_name": "[^"]*' | grep -o '[^"]*$' | cut -c 2-) -if [ -z "$latest_release" ]; +if [ -z "$latest_release" ] then abort "Failed to retrieve the latest release" fi filename="frp_${latest_release}_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m)" diff --git a/scripts/obs-install.sh b/scripts/obs-install.sh index 10978c71..a11dd4af 100644 --- a/scripts/obs-install.sh +++ b/scripts/obs-install.sh @@ -5,12 +5,12 @@ abort() { exit 1 } -if [ "${EUID:-$(id -u)}" -ne 0 ]; +if [ "${EUID:-$(id -u)}" -ne 0 ] then abort "Error: This script requires root permission" fi execute() { - if ! "$@"; + if ! "$@" then abort "$(printf "Failed: %s" "$@")" fi } diff --git a/scripts/obs-run.sh b/scripts/obs-run.sh index 87047950..d08b71c5 100644 --- a/scripts/obs-run.sh +++ b/scripts/obs-run.sh @@ -5,12 +5,12 @@ abort() { exit 1 } -if [ "${EUID:-$(id -u)}" -ne 0 ]; +if [ "${EUID:-$(id -u)}" -ne 0 ] then abort "Error: This script requires root permission" fi execute() { - if ! "$@"; + if ! "$@" then abort "$(printf "Failed: %s" "$@")" fi } diff --git a/scripts/python-install.sh b/scripts/python-install.sh index 6a50a07d..33bf3d0c 100644 --- a/scripts/python-install.sh +++ b/scripts/python-install.sh @@ -5,12 +5,12 @@ abort() { exit 1 } -if [ "${EUID:-$(id -u)}" -ne 0 ]; +if [ "${EUID:-$(id -u)}" -ne 0 ] then abort "Error: This script requires root permission" fi execute() { - if ! "$@"; + if ! "$@" then abort "$(printf "Failed: %s" "$@")" fi } diff --git a/scripts/setup.sh b/scripts/setup.sh index 6c7ea570..2d1f95ae 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -5,12 +5,12 @@ abort() { exit 1 } -if [ "${EUID:-$(id -u)}" -ne 0 ]; +if [ "${EUID:-$(id -u)}" -ne 0 ] then abort "Error: This script requires root permission" fi execute() { - if ! "$@"; + if ! "$@" then abort "$(printf "Failed: %s" "$@")" fi }