11#! /bin/bash
2- #! /bin/bash
2+
33
44if [ $( id -u) -ne 0 ]; then
55 echo -e " \e[31mERROR: Not root user\e[0m"
@@ -14,19 +14,20 @@ RAW_REPO="$RAW_PREFIX/$REPO"
1414BASE_PATH=/opt/py-openbmclapi
1515USERNAME=openbmclapi
1616PY_MIRCO=3.10
17- if ! PY_VERSION=$( python -V 2>&1 | awk ' {print $2}' ) ; then
17+ if ! PY_VERSION=$( python -V 2>&1 | awk ' {print $2}' ) && $( python -V 2>&1 | awk ' {print $2} ' | awk -F ' . ' ' {print $1} ' ) -lt 3 ; then
1818 echo -e " \e[31mERROR: Failed to detect python version\e[0m"
1919 exit 1
2020fi
21-
22- different=$( echo 2>&1 | awk " {print $PY_VERSION -$PY_MIRCO }" )
23- compare=$( expr $different \> 0)
24- if [[ $compare -eq 1 ]] ; then
21+ PY_VERSION=$( python -V 2>&1 | awk ' {print $2}' | awk -F ' .' ' {print $1}' ) .$( python -V 2>&1 | awk ' {print $2}' | awk -F ' .' ' {print $2}' )
22+ different=$( echo 2>&1 | awk " {print $PY_VERSION - $PY_MIRCO }" )
23+ compare=$( expr " $different " \> 0)
24+ printf $compare
25+ if [[ $compare -eq 0 ]] ; then
2526 echo -e " \e[31mERROR: Python version not supported;need >=3.10\e[0m"
2627 exit 1
2728fi
2829
29- if ! systemd --version > /dev/null 2>&1 ; then
30+ if ! systemctl --version > /dev/null 2>&1 ; then
3031 echo -e " \e[31mERROR: Failed to test systemd\e[0m"
3132 exit 1
3233fi
@@ -72,7 +73,7 @@ function fetchBlob(){
7273
7374echo
7475
75- if [ -f /usr/lib/systemd/system/go -openbmclapi.service ]; then
76+ if [ -f /usr/lib/systemd/system/py -openbmclapi.service ]; then
7677 echo -e " \e[33m==> WARN: py-openbmclapi.service is already installed, stopping\e[0m"
7778 systemctl disable --now py-openbmclapi.service
7879fi
@@ -86,11 +87,11 @@ if [ ! -n "$TARGET_TAG" ]; then
8687 echo
8788fi
8889
89- fetchBlob service /py-openbmclapi.service /usr/lib/systemd/system/py-openbmclapi.service 0644 || exit $?
90+ fetchBlob installer /py-openbmclapi.service /usr/lib/systemd/system/py-openbmclapi.service 0644 || exit $?
9091
9192[ -d " $BASE_PATH " ] || { mkdir -p " $BASE_PATH " && chmod 0755 " $BASE_PATH " && chown $USERNAME " $BASE_PATH " ; } || exit $?
9293
93- # fetchBlob service /start-server .sh "$BASE_PATH/start-server .sh" 0755 || exit $?
94+ fetchBlob installer /start.sh " $BASE_PATH /start.sh" 0755 || exit $?
9495# fetchBlob service/stop-server.sh "$BASE_PATH/stop-server.sh" 0755 || exit $?
9596# fetchBlob service/reload-server.sh "$BASE_PATH/reload-server.sh" 0755 || exit $?
9697
@@ -106,8 +107,8 @@ systemctl enable py-openbmclapi.service || exit $?
106107echo -e "
107108================================ Install successed ================================
108109
109- Use 'systemctl start go -openbmclapi.service' to start openbmclapi server
110- Use 'systemctl stop go -openbmclapi.service' to stop openbmclapi server
111- Use 'systemctl reload go -openbmclapi.service' to reload openbmclapi server configs
112- Use 'journalctl -f --output cat -u go -openbmclapi.service' to watch the openbmclapi logs
110+ Use 'systemctl start py -openbmclapi.service' to start openbmclapi server
111+ Use 'systemctl stop py -openbmclapi.service' to stop openbmclapi server
112+ Use 'systemctl reload py -openbmclapi.service' to reload openbmclapi server configs
113+ Use 'journalctl -f --output cat -u py -openbmclapi.service' to watch the openbmclapi logs
113114"
0 commit comments