diff --git a/README.md b/README.md index e7aaa18c..04d53416 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Cool Stuffs! Hardware --------------------------- -I am currently selling fully set up Joustmania devices (pi 4gb model, case, bluetooth dongle, sd card) for $140 (or the tiers on [patreon](https://www.patreon.com/adangert)) with included shipping domestically. If you would like to inquire about purchasing a fully setup Joustmania device, please reach out to joustmaniagame@gmail.com +I am currently selling fully set up Joustmania devices (pi 4gb model, case, bluetooth dongle, sd card) for $200 with included shipping domestically. If you would like to inquire about purchasing a fully setup Joustmania device, please reach out to joustmaniagame@gmail.com If you would like to build your own device you will need the following: @@ -78,7 +78,7 @@ Pairing controllers If pairing is not working for some reason, or you would like to resync all controllers run the following ``` -cd /home/pi/JoustMania/ +cd JoustMania sudo ./reset_bluetooth_connections.sh ``` diff --git a/audio_tool.py b/audio_tool.py index 38d52695..300aafc7 100755 --- a/audio_tool.py +++ b/audio_tool.py @@ -1,4 +1,4 @@ -#!/home/pi/JoustMania/venv/bin/python3.6 + import asyncio import sys diff --git a/color_tests/pythonpath.sh b/color_tests/pythonpath.sh index 45bd1e94..868e4a07 100644 --- a/color_tests/pythonpath.sh +++ b/color_tests/pythonpath.sh @@ -1 +1,5 @@ -export PYTHONPATH=/home/pi/psmoveapi/build/ +#sets the username of the system, supervisord does not have a login +#so we need to use the who command. +HOMENAME=`who | head -n1 | cut -d " " -f1` + +export PYTHONPATH=/home/$HOMENAME/psmoveapi/build/ diff --git a/conf/supervisor/conf.d/joust.conf b/conf/supervisor/conf.d/joust.conf index 4d28c472..e4f60925 100755 --- a/conf/supervisor/conf.d/joust.conf +++ b/conf/supervisor/conf.d/joust.conf @@ -1,6 +1,7 @@ [program:joustmania] command=/home/pi/JoustMania/joust.sh -user=root directory=/home/pi/JoustMania/ autorestart=true startretries=1000 +stderr_logfile=/var/log/joustmania-err.log +stdout_logfile=/var/log/joustmania-out.log diff --git a/controller_util.py b/controller_util.py index b80e1c57..c90aaedc 100755 --- a/controller_util.py +++ b/controller_util.py @@ -1,5 +1,3 @@ -#!/home/pi/JoustMania/venv/bin/python3.6 - import asyncio import psmove import player diff --git a/joust.sh b/joust.sh index 5ad8a255..80194870 100755 --- a/joust.sh +++ b/joust.sh @@ -5,6 +5,10 @@ if [ $UID -ne 0 ]; then exec sudo $0 fi -export HOME="/home/pi/JoustMania" -export PYTHONPATH="/home/pi/psmoveapi/build/" -exec /home/pi/JoustMania/venv/bin/python3 /home/pi/JoustMania/piparty.py +#sets the username of the system, supervisord does not have a login +#so we need to use the who command. +HOMENAME=`who | head -n1 | cut -d " " -f1` + +export HOME="/home/$HOMENAME/JoustMania" +export PYTHONPATH="/home/$HOMENAME/psmoveapi/build/" +exec /home/$HOMENAME/JoustMania/venv/bin/python3 /home/$HOMENAME/JoustMania/piparty.py diff --git a/manualpair.py b/manualpair.py index 1fb8f155..ff72b531 100644 --- a/manualpair.py +++ b/manualpair.py @@ -1,7 +1,8 @@ import sys import os import time -sys.path.insert(0, '/home/pi/psmoveapi/build/') +add_dir = '{}/../psmoveapi/build/'.format(os.getcwd()) +sys.path.insert(0, add_dir) import psmove import pair diff --git a/setup.sh b/setup.sh index b74f1282..a8704413 100755 --- a/setup.sh +++ b/setup.sh @@ -3,12 +3,15 @@ setup() { # Prevent apt from prompting us about restarting services. export DEBIAN_FRONTEND=noninteractive + HOMENAME=`logname` + HOMEDIR=/home/$HOMENAME + cd $HOMEDIR sudo apt-get install -y espeak - + espeak "starting software upgrade" sudo apt-get update -y || exit -1 sudo apt-get upgrade -y || exit -1 - cd /home/pi + espeak "Installing required software dependencies" #TODO: remove pyaudio and dependencies #install components @@ -33,7 +36,7 @@ setup() { libusb-dev || exit -1 espeak "Installing software libraries" - VENV=/home/pi/JoustMania/venv + VENV=$HOMEDIR/JoustMania/venv # We install nearly all python deps in the virtualenv to avoid concflicts with system, except # numpy and scipy because they take forever to build. sudo apt-get install -y libasound2-dev libasound2 python3-scipy cmake || exit -1 @@ -70,9 +73,14 @@ setup() { -DPSMOVE_BUILD_TRACKER:BOOL=OFF \ -DPSMOVE_USE_PSEYE:BOOL=OFF make -j4 - + + #change the supervisord directory to our own homename + #this replaces pi default username in joust.conf, + sed -i -e "s/pi/$HOMENAME/g" $HOMEDIR/JoustMania/conf/supervisor/conf.d/joust.conf + + #installs custom supervisor script for running joustmania on startup - sudo cp -r /home/pi/JoustMania/conf/supervisor/ /etc/ + sudo cp -r $HOMEDIR/JoustMania/conf/supervisor/ /etc/ #Use amixer to set sound output to 100% amixer sset PCM,0 100% @@ -86,10 +94,10 @@ setup() { sudo systemctl disable hciuart || exit -1 fi - uname2="$(stat --format '%U' '/home/pi/JoustMania/setup.sh')" - uname3="$(stat --format '%U' '/home/pi/JoustMania/piparty.py')" + uname2="$(stat --format '%U' $HOMEDIR'/JoustMania/setup.sh')" + uname3="$(stat --format '%U' $HOMEDIR'/JoustMania/piparty.py')" if [ "${uname2}" = "root" ] || [ "${uname3}" = "root" ] ; then - sudo chown -R pi:pi /home/pi/JoustMania/ + sudo chown -R $HOMENAME:$HOMENAME $HOMEDIR/JoustMania/ espeak "permisions updated, please wait after reboot for Joustmania to start" else echo "no permissions to update" diff --git a/test_controller_util.py b/test_controller_util.py index 2e5219d2..a873ebb2 100755 --- a/test_controller_util.py +++ b/test_controller_util.py @@ -5,6 +5,8 @@ exec sudo $0 fi -export HOME="/home/pi/JoustMania" -export PYTHONPATH="/home/pi/psmoveapi/build/" -exec /home/pi/JoustMania/venv/bin/python3 /home/pi/JoustMania/controller_util.py +#sets the username, supervisord does not have a login when running joustmania +HOMENAME=`who | head -n1 | cut -d " " -f1` +export HOME="/home/$HOMENAME/JoustMania" +export PYTHONPATH="/home/$HOMENAME/psmoveapi/build/" +exec /home/$HOMENAME/JoustMania/venv/bin/python3 /home/$HOMENAME/JoustMania/controller_util.py diff --git a/tests b/tests index 3ee63946..48cc9c37 100755 --- a/tests +++ b/tests @@ -1,5 +1,9 @@ #!/bin/bash -export HOME="/home/pi/JoustMania" +#sets the username of the system, supervisord does not have a login +#so we need to use the who command. +HOMENAME=`who | head -n1 | cut -d " " -f1` + +export HOME="/home/$HOMENAME/JoustMania" exec $HOME/venv/bin/python3.6 -m unittest discover -s . -p '*_test.py' diff --git a/update.py b/update.py index 3218587f..ea7bcabb 100644 --- a/update.py +++ b/update.py @@ -3,6 +3,7 @@ from piaudio import Audio, InitAudio import time import shlex +import os if __name__ == "__main__": InitAudio() @@ -24,13 +25,13 @@ def run_command(command): def big_update(voice): Audio('audio/Menu/vox/' + voice + '/update_started.wav').start_effect_and_wait() - current_hash = run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git rev-parse HEAD'").strip() - run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git checkout master'") - run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git pull'") - run_command("sudo /home/pi/JoustMania/setup.sh") + current_hash = run_command("sudo runuser -l pi -c 'cd {};git rev-parse HEAD'".format(os.getcwd())).strip() + run_command("sudo runuser -l pi -c 'cd {};git checkout master'".format(os.getcwd())) + run_command("sudo runuser -l pi -c 'cd {};git pull'".format(os.getcwd())) + run_command("sudo /home/{}/JoustMania/setup.sh".format(os.getlogin())) #it failed if it got this far time.sleep(3) - run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git checkout {}'".format(current_hash)) + run_command("sudo runuser -l pi -c 'cd {};git checkout {}'".format(os.getcwd(),current_hash)) Audio('audio/Menu/vox/' + voice + '/joustmania_failed.wav').start_effect_and_wait() def tester(): @@ -38,9 +39,14 @@ def tester(): print(current_hash) def check_for_update(voice): - process = run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;pwd'") - process = run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git fetch'") - diff_files = run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git diff origin/master --name-only --cached'").split() + print("checking out login@@@@@@@@@@@@@@@@@@@") + print(os.getcwd()) + print(os.path.expanduser('~')) + print(os.environ.get("USERNAME")) + #print(os.getlogin()) + process = run_command("sudo runuser -l pi -c 'cd {};pwd'".format(os.getcwd())) + process = run_command("sudo runuser -l pi -c 'cd {};git fetch'".format(os.getcwd())) + diff_files = run_command("sudo runuser -l pi -c 'cd {};git diff origin/master --name-only --cached'".format(os.getcwd())).split() print(diff_files) @@ -50,7 +56,7 @@ def check_for_update(voice): elif (len(diff_files) >= 1): print("doing small pull") - pull = run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git pull'") + pull = run_command("sudo runuser -l pi -c 'cd {};git pull'".format(os.getcwd())) Audio('audio/Menu/vox/' + voice + '/joustmania_updated.wav').start_effect_and_wait() return False diff --git a/webui.sh b/webui.sh index 70f98677..7fae7bc8 100755 --- a/webui.sh +++ b/webui.sh @@ -8,6 +8,10 @@ if [ $UID -ne 0 ]; then exec sudo $0 fi -export HOME="/home/pi/JoustMania" -export PYTHONPATH="/home/pi/psmoveapi/build/" -/home/pi/JoustMania/venv/bin/python3.6 /home/pi/JoustMania/webui.py +#sets the username of the system, supervisord does not have a login +#so we need to use the who command. +HOMENAME=`who | head -n1 | cut -d " " -f1` + +export HOME="/home/$HOMENAME/JoustMania" +export PYTHONPATH="/home/$HOMENAME/psmoveapi/build/" +/home/$HOMENAME/JoustMania/venv/bin/python3.6 /home/$HOMENAME/JoustMania/webui.py