'How can I create new linux screen without using root but with python started as root
My code is:
import RPi.GPIO as GPIO
import subprocess
import time
import os
isBungeeCord = False
serverPath = "/TheJebScream"
powerPIN = 3
screenName = "minecraft"
def startListening(GPIO_PIN, screen):
GPIO.setmode(GPIO.BCM)
GPIO.setup(GPIO_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(GPIO_PIN, GPIO.FALLING)
subprocess.call(["screen", "-Rd", screen, "-X", "stuff", 'stop\r'], shell=False)
while str(subprocess.Popen(["screen", "-ls"], shell=False, stdout=subprocess.PIPE).stdout.readlines()).find(screen) != -1:
time.sleep(1)
subprocess.call(["screen", "-X", "-S", screen, "kill"], shell=False)
subprocess.call(["sudo", "shutdown", "-h", "now"], shell=False)
def startMC(screen):
subprocess.call(["screen", "-dmS", screen, "java", "-Xmx4G", "-Xms4G", "-jar", "server.jar"], shell=False)
os.chdir(serverPath)
startMC(screenName)
startListening(powerPIN, screenName)
That problem is in the function startMC. It just doesnt work with root but I need to run that python program as root becose I need to shutdown my rpi and it only works with root.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
