Skip to content

Commit 40daf3c

Browse files
authored
Merge pull request #287 from ton-blockchain/mytonctrl1_dev
Add set_state_ttl script
2 parents 3257127 + f48f8bc commit 40daf3c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

scripts/set_state_ttl.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import subprocess
2+
import sys
3+
4+
with open('/etc/systemd/system/validator.service', 'r') as file:
5+
service = file.read()
6+
7+
8+
for line in service.split('\n'):
9+
if line.startswith('ExecStart'):
10+
exec_start = line
11+
break
12+
13+
14+
if exec_start.split(' ')[2] != '/usr/bin/ton/validator-engine/validator-engine':
15+
raise Exception('Invalid node start command in service file')
16+
17+
18+
if '--state-ttl 604800' not in exec_start:
19+
print('No state-ttl or custom one found in ExecStart')
20+
sys.exit(0)
21+
22+
new_exec_start = exec_start.replace('--state-ttl 604800', '')
23+
24+
with open('/etc/systemd/system/validator.service', 'w') as file:
25+
file.write(service.replace(exec_start, new_exec_start))
26+
27+
subprocess.run(['systemctl', 'daemon-reload'])
28+
subprocess.run(['systemctl', 'restart', 'validator'])
29+
30+
print('Removed state-ttl from service file.')

scripts/upgrade.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ cmake -DCMAKE_BUILD_TYPE=Release ${srcdir}/${repo} -GNinja -DTON_USE_JEMALLOC=ON
7676
ninja -j ${cpuNumber} fift validator-engine lite-client pow-miner validator-engine-console generate-random-id dht-server func tonlibjson rldp-http-proxy
7777
systemctl restart validator
7878

79+
if [ -e /usr/src/mytonctrl/scripts/set_state_ttl.py ]
80+
then
81+
/usr/bin/python3 /usr/src/mytonctrl/scripts/set_state_ttl.py
82+
else
83+
echo "Set state ttl script is not found!"
84+
fi
85+
86+
7987
# Конец
8088
echo -e "${COLOR}[1/1]${ENDC} TON components update completed"
8189
exit 0

0 commit comments

Comments
 (0)