Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Remove executable bit from logfiles #2038

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openwb-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ fi

echo "www-data ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/010_pi-nopasswd

chmod 777 /var/www/html/openWB/openwb.conf
chmod ugo=rwX /var/www/html/openWB/openwb.conf
chmod +x /var/www/html/openWB/modules/*
chmod +x /var/www/html/openWB/runs/*
chmod +x /var/www/html/openWB/*.sh
touch /var/log/openWB.log
chmod 777 /var/log/openWB.log
chmod ugo=rwX /var/log/openWB.log
/var/www/html/openWB/runs/atreboot.sh
31 changes: 12 additions & 19 deletions runs/atreboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,18 @@ mkdir -p /var/www/html/openWB/web/backup
touch /var/www/html/openWB/web/backup/.donotdelete
sudo chown -R www-data:www-data /var/www/html/openWB/web/backup
sudo chown -R www-data:www-data /var/www/html/openWB/web/tools/upload
sudo chmod 777 /var/www/html/openWB/openwb.conf
sudo chmod 777 /var/www/html/openWB/smarthome.ini
sudo chmod 777 /var/www/html/openWB/ramdisk
sudo chmod 777 /var/www/html/openWB/ramdisk/
sudo chmod 777 /var/www/html/openWB/web/files/*
sudo chmod -R +x /var/www/html/openWB/modules/*

sudo chmod -R 777 /var/www/html/openWB/modules/soc_i3
sudo chmod -R 777 /var/www/html/openWB/modules/soc_eq
sudo chmod -R 777 /var/www/html/openWB/modules/soc_tesla

sudo chmod 777 /var/www/html/openWB/web/files/*
sudo chmod -R +x /var/www/html/openWB/modules/*
sudo chmod ugo=rwX /var/www/html/openWB/openwb.conf
sudo chmod ugo=rwX /var/www/html/openWB/smarthome.ini
sudo chmod -R ugo=rwX /var/www/html/openWB/ramdisk/
sudo chmod -R ugo=rwX /var/www/html/openWB/web/files/
sudo chmod -R ugo=rwx /var/www/html/openWB/modules/

mkdir -p /var/www/html/openWB/web/logging/data/daily
mkdir -p /var/www/html/openWB/web/logging/data/monthly
mkdir -p /var/www/html/openWB/web/logging/data/ladelog
mkdir -p /var/www/html/openWB/web/logging/data/v001
sudo chmod -R 777 /var/www/html/openWB/web/logging/data/
sudo chmod -R ugo=rwX /var/www/html/openWB/web/logging/data/
sudo chmod +x /var/www/html/openWB/packages/*.sh

# update openwb.conf
Expand Down Expand Up @@ -349,7 +342,7 @@ curl --connect-timeout 10 -d "update="$releasetrain$uuid"vers"$owbv"" -H "Conten
echo "clear warning..."
echo "" > /var/www/html/openWB/ramdisk/lastregelungaktiv
echo "" > /var/www/html/openWB/ramdisk/mqttlastregelungaktiv
chmod 777 /var/www/html/openWB/ramdisk/mqttlastregelungaktiv
chmod ugo=rwX /var/www/html/openWB/ramdisk/mqttlastregelungaktiv

# check for slave config and start handler
if (( isss == 1 )); then
Expand Down Expand Up @@ -415,8 +408,8 @@ sudo git -C /var/www/html/openWB show --pretty='format:%ci [%h]' | head -n1 > /v
commitId=`git -C /var/www/html/openWB log --format="%h" -n 1`
echo $commitId > /var/www/html/openWB/ramdisk/currentCommitHash
echo `git -C /var/www/html/openWB branch -a --contains $commitId | perl -nle 'm|.*origin/(.+).*|; print $1' | uniq | xargs` > /var/www/html/openWB/ramdisk/currentCommitBranches
sudo chmod 777 /var/www/html/openWB/ramdisk/currentCommitHash
sudo chmod 777 /var/www/html/openWB/ramdisk/currentCommitBranches
sudo chmod ugo=rwX /var/www/html/openWB/ramdisk/currentCommitHash
sudo chmod ugo=rwX /var/www/html/openWB/ramdisk/currentCommitBranches

# update broker
echo "update broker..."
Expand All @@ -443,9 +436,9 @@ rm -rf /var/www/html/openWB/web/themes/dark19_01
(sleep 10; mosquitto_pub -t openWB/set/ChargeMode -r -m "$bootmodus") &
(sleep 10; mosquitto_pub -t openWB/global/ChargeMode -r -m "$bootmodus") &
echo " " > /var/www/html/openWB/ramdisk/lastregelungaktiv
chmod 777 /var/www/html/openWB/ramdisk/lastregelungaktiv
chmod 777 /var/www/html/openWB/ramdisk/smarthome.log
chmod 777 /var/www/html/openWB/ramdisk/smarthomehandlerloglevel
chmod ugo=rwX /var/www/html/openWB/ramdisk/lastregelungaktiv
chmod ugo=rwX /var/www/html/openWB/ramdisk/smarthome.log
chmod ugo=rwX /var/www/html/openWB/ramdisk/smarthomehandlerloglevel

# update etprovider pricelist
echo "etprovider..."
Expand Down
8 changes: 4 additions & 4 deletions runs/csvcalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def fillcount(row, datestring, file_stringo, firstfile):
f1 = open(file_stringo, 'w')
f1.write(str(headerst))
f1.close()
os.chmod(file_stringo, 0o777)
os.chmod(file_stringo, 0o666)
else:
f1 = open(file_stringo, 'a')
excelstring = exceldate(countercsv[0])
Expand Down Expand Up @@ -329,7 +329,7 @@ def fillcounts(monhtrow, file_stringos, lastdate, lastzeit):
line = line + str(0) + '\n'
f1.write(str(line))
f1.close()
os.chmod(file_stringos, 0o777)
os.chmod(file_stringos, 0o666)
print('%s %s written' % (getTime(), file_stringos))
for i in range(1, SUMCOLUMNSTART):
if (i < len(monhtrow)):
Expand Down Expand Up @@ -396,13 +396,13 @@ def reyeardet(calcyear):
print('%s Yearerror %s inhalt %s' % (getTime(), file_stringis, str(e)))
if (validdata == 1):
f1.close()
os.chmod(file_stringo, 0o777)
os.chmod(file_stringo, 0o666)
f1 = open(file_stringos, 'w')
line = 'Anzahl Spalten,' + str(startspalten) + ',Letzes Datum,' + complastdate + ',Letzte Zeit,' + complastzeit + ', \n'
f1.write(str(line))
f1.write(str(headerline))
f1.close()
os.chmod(file_stringos, 0o777)
os.chmod(file_stringos, 0o666)
print('%s %s written' % (getTime(), file_stringos))
return

Expand Down
14 changes: 7 additions & 7 deletions runs/csvselmonth.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def selmonth(jjjjmm):
f1 = open( outputfile + 'a_onl3', 'w')
f1.write(str(sumlineb))
f1.close()
os.chmod(outputfile + 'a_onl1', 0o777)
os.chmod(outputfile + 'a_onl2', 0o777)
os.chmod(outputfile + 'a_onl3', 0o777)
os.chmod(outputfile + 'a_onl1', 0o666)
os.chmod(outputfile + 'a_onl2', 0o666)
os.chmod(outputfile + 'a_onl3', 0o666)
#lesen gesamtes monatsfile
ifile=0
try:
Expand Down Expand Up @@ -141,10 +141,10 @@ def selmonth(jjjjmm):
f2.close()
f3.close()
f4.close()
os.chmod(outputfile + 'a_onl4', 0o777)
os.chmod(outputfile + 'a_onl5', 0o777)
os.chmod(outputfile + 'a_onl6', 0o777)
os.chmod(outputfile + 'a_onl7', 0o777)
os.chmod(outputfile + 'a_onl4', 0o666)
os.chmod(outputfile + 'a_onl5', 0o666)
os.chmod(outputfile + 'a_onl6', 0o666)
os.chmod(outputfile + 'a_onl7', 0o666)
except Exception as e:
print ('%s error1 %s inhalt %s' % (getTime(),datestring, str(e) ))
if (ifile == 0):
Expand Down
6 changes: 3 additions & 3 deletions runs/csvselyear.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def selyear(jjjjmm):
f1 = open( outputfile + 'b_onl1', 'w')
f1.write(str(headerline))
f1.close()
os.chmod(outputfile + 'b_onl1', 0o777)
os.chmod(outputfile + 'b_onl1', 0o666)
#lesen gesamtes Jahresfile
ifile=0
try:
Expand Down Expand Up @@ -116,8 +116,8 @@ def selyear(jjjjmm):
f.close()
f1.close()
f2.close()
os.chmod(outputfile + 'b_onl4', 0o777)
os.chmod(outputfile + 'b_onl5', 0o777)
os.chmod(outputfile + 'b_onl4', 0o666)
os.chmod(outputfile + 'b_onl5', 0o666)
except Exception as e:
print ('%s error1 %s inhalt %s' % (getTime(),file_cvsfinp, str(e) ))
if (ifile == 0):
Expand Down
2 changes: 1 addition & 1 deletion runs/initRamdisk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ initRamdisk(){
fi
echo $importtemp > $RamdiskPath/smarthomehandlermaxbatterypower

sudo chmod 777 $RamdiskPath/*
sudo chmod ugo=rwX $RamdiskPath/*

echo "Trigger update of logfiles..."
python3 /var/www/html/openWB/runs/csvcalc.py --input /var/www/html/openWB/web/logging/data/daily/ --output /var/www/html/openWB/web/logging/data/v001/ --partial /var/www/html/openWB/ramdisk/ --mode M >> /var/www/html/openWB/ramdisk/csvcalc.log 2>&1 &
Expand Down
2 changes: 1 addition & 1 deletion runs/reboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

sudo rm /var/log/openWB.log
sudo touch /var/log/openWB.log
sudo chmod 777 /var/log/openWB.log
sudo chmod ugo=rwX /var/log/openWB.log
$(sleep 5 && sudo reboot now)&
2 changes: 1 addition & 1 deletion runs/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sudo tar -vxf backup.tar.gz
echo "****************************************"
echo "Step 3: replacing old files..."
sudo cp -v -R /home/pi/var/www/html/openWB/* /var/www/html/openWB/
sudo chmod 777 /var/www/html/openWB/openwb.conf
sudo chmod ugo=rwX /var/www/html/openWB/openwb.conf
echo "****************************************"
echo "Step 4: cleanup after restore..."
sudo rm /var/www/html/openWB/web/tools/upload/backup.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion runs/shutdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

sudo rm /var/log/openWB.log
sudo touch /var/log/openWB.log
sudo chmod 777 /var/log/openWB.log
sudo chmod ugo=rwX /var/log/openWB.log
$(sleep 5 && sudo shutdown now)&
2 changes: 1 addition & 1 deletion runs/smarthomehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
f = open(filename, 'w')
f.write(str("0"))
f.close()
os.chmod(filename, 0o777)
os.chmod(filename, 0o666)
global numberOfDevices

def cleardef(nummer):
Expand Down
2 changes: 1 addition & 1 deletion runs/transferladelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ if [ -e /var/www/html/openWB/web/ladelog ]; then
done < "$oldlog"
rm /var/www/html/openWB/web/ladelog
chown -R pi:pi /var/www/html/openWB/web/logging/data/ladelog/
chmod 777 /var/www/html/openWB/web/logging/data/ladelog/*
chmod ugo=rwX /var/www/html/openWB/web/logging/data/ladelog/*

fi
8 changes: 4 additions & 4 deletions runs/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo 1 > /var/www/html/openWB/ramdisk/bootinprogress
echo "Update im Gange, bitte warten bis die Meldung nicht mehr sichtbar ist" > /var/www/html/openWB/ramdisk/lastregelungaktiv
mosquitto_pub -t "openWB/global/strLastmanagementActive" -r -m "Update im Gange, bitte warten bis die Meldung nicht mehr sichtbar ist"
echo "Update im Gange, bitte warten bis die Meldung nicht mehr sichtbar ist" > /var/www/html/openWB/ramdisk/mqttlastregelungaktiv
chmod 777 /var/www/html/openWB/ramdisk/mqttlastregelungaktiv
chmod ugo=rwX /var/www/html/openWB/ramdisk/mqttlastregelungaktiv

# The update might replace a number of files which might currently be in use by the continuously running legacy-run
# server. If we replace the source files while the process is running, funny things might happen.
Expand Down Expand Up @@ -83,12 +83,12 @@ sudo cp /tmp/soc_eq_acc_lp1 /var/www/html/openWB/modules/soc_eq/soc_eq_acc_lp1
sudo cp /tmp/soc_eq_acc_lp2 /var/www/html/openWB/modules/soc_eq/soc_eq_acc_lp2

# set permissions
sudo chmod 777 /var/www/html/openWB/openwb.conf
sudo chmod ugo=rwX /var/www/html/openWB/openwb.conf
sudo chmod +x /var/www/html/openWB/modules/*
sudo chmod +x /var/www/html/openWB/runs/*
sudo chmod +x /var/www/html/openWB/*.sh
sudo chmod 777 /var/www/html/openWB/ramdisk/*
sudo chmod 777 /var/www/html/openWB/web/lade.log
sudo chmod ugo=rwX /var/www/html/openWB/ramdisk/*
sudo chmod ugo=rwX /var/www/html/openWB/web/lade.log
sleep 2

# now treat system as in booting state
Expand Down
2 changes: 1 addition & 1 deletion zielladen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ziellademodus(){
if (( ladestatus == 1 )); then
echo 0 > ramdisk/ladungdurchziel
echo 0 > ramdisk/zielladenkorrektura
sed -e "s/zielladenaktivlp1=.*/zielladenaktivlp1=0/" openwb.conf > ramdisk/openwb.conf && mv ramdisk/openwb.conf openwb.conf && chmod 777 openwb.conf
sed -e "s/zielladenaktivlp1=.*/zielladenaktivlp1=0/" openwb.conf > ramdisk/openwb.conf && mv ramdisk/openwb.conf openwb.conf && chmod ugo=rwX openwb.conf
runs/set-current.sh 0 m
fi
else
Expand Down