Skip to content

Commit

Permalink
move new scripts into their own directory and start some migration code
Browse files Browse the repository at this point in the history
  • Loading branch information
ZXGuesser committed Jan 16, 2023
1 parent c9cb79f commit 9758fa7
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 28 deletions.
5 changes: 3 additions & 2 deletions getvbit2
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ make
# create links
mkdir -p $HOME/.local/bin
ln -s -f `pwd`/vbit2 $HOME/.local/bin/
ln -s -f `pwd`/runvbit2.sh $HOME/.local/bin/
ln -s -f `pwd`/vbit-config $HOME/.local/bin/
ln -s -f `pwd`/scripts/runvbit2.py $HOME/.local/bin/runvbit2
ln -s -f `pwd`/scripts/teletext-update.py $HOME/.local/bin/teletext-update
ln -s -f `pwd`/scripts/vbit-config.py $HOME/.local/bin/vbit-config

# install systemd user scripts
mkdir -p $HOME/.local/share/systemd/user
Expand Down
30 changes: 27 additions & 3 deletions postupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ main(){
# recompile vbit2
make

sudo apt -y install python3-dialog
sudo apt -qq -y install python3-dialog

# remove old symlink
rm $HOME/.local/bin/runvbit2.sh 2>/dev/null

# create links
mkdir -p $HOME/.local/bin
ln -s -f `pwd`/vbit2 $HOME/.local/bin/
ln -s -f `pwd`/runvbit2.sh $HOME/.local/bin/
ln -s -f `pwd`/vbit-config $HOME/.local/bin/
ln -s -f `pwd`/scripts/runvbit2.py $HOME/.local/bin/runvbit2
ln -s -f `pwd`/scripts/teletext-update.py $HOME/.local/bin/teletext-update
ln -s -f `pwd`/scripts/vbit-config.py $HOME/.local/bin/vbit-config

# install systemd user scripts
mkdir -p $HOME/.local/share/systemd/user
Expand All @@ -37,6 +41,9 @@ main(){

cleanoldunits

# warn about removing old services
migratejson

# restart vbit if service is active
if [[ `systemctl --user is-active vbit2.service` == "active" ]]; then
systemctl --user restart vbit2.service
Expand Down Expand Up @@ -96,4 +103,21 @@ migrate(){
fi
}

migratejson(){
if [ -f $HOME/.teletext-services/config ]; then
printf 'This version of VBIT2 uses a new config format and directory scheme.\nServices will not be automatically migrated so must be reinstalled.\nThe following services were found:\n'
ls -d1 ~/.teletext-services/*/

read -n 1 -s -r -p "Do you wish to create a backup of these services? (y/N)"
if [[ $REPLY =~ ^[Yy]$ ]]; then
printf '\nbacking up old services to %s\n' "$HOME/teletext-services.bak"
mv $HOME/.teletext-services $HOME/teletext-services.bak
else
rm -rf $HOME/.teletext-services/ 2>/dev/null
fi

vbit-config
fi
}

main; exit
4 changes: 3 additions & 1 deletion config.py → scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def uninstallService(name):
def installService(service):
configData = load()

if not service.get("name") or not service.get("type") or not service.get("url") or not service.get("path"):
if not service.get("name") or not service.get("type") or not service.get("path"):
raise RuntimeError("invalid service configuration data\n{0}".format(service))

installedNames = []
Expand All @@ -103,6 +103,8 @@ def installService(service):
if not os.path.exists(service["path"]):
raise RuntimeError("Directory does not exist")
else:
if not service.get("url"):
raise RuntimeError("invalid service configuration data\n{0}".format(service))
doServiceInstall(service["type"], service["path"], service["url"])

serviceConfigObject = {"name":service["name"], "type":service["type"], "path":service["path"]}
Expand Down
26 changes: 12 additions & 14 deletions known_services.json → scripts/known_services.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
"services":[
{"name":"Teefax","type":"svn","url":"http://teastop.plus.com/svn/teletext/","path":"Teefax"},
{"name":"Ceefax","type":"group","services":[
{"name":"Ceefax (East)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/East","path":"CeefaxEast", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":"True"}]},
{"name":"Ceefax (East Midlands)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/EastMidlands","path":"CeefaxEastMids", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":"True"}]},
{"name":"Ceefax (London)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/London","path":"CeefaxLondon", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":"True"}]},
{"name":"Ceefax (Northern Ireland)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/NorthernIreland","path":"CeefaxNI", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":"True"}]},
{"name":"Ceefax (Scotland)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/Scotland","path":"CeefaxScotland", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":"True"}]},
{"name":"Ceefax (South)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/South","path":"CeefaxSouth", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":"True"}]},
{"name":"Ceefax (South West)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/SouthWest","path":"CeefaxSouthWest", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":"True"}]},
{"name":"Ceefax (Wales)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/Wales","path":"CeefaxWales", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":"True"}]},
{"name":"Ceefax (West)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/West","path":"CeefaxWest", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":"True"}]},
{"name":"Ceefax (Worldwide)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/Worldwide","path":"CeefaxWorldwide", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":"True"}]},
{"name":"Ceefax (Yorks and Lincs)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/Yorks&Lincs","path":"CeefaxYorksAndLincs", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":"True"}]}
]},
{"name":"Chunkytext","type":"git","url":"https://zxnet.co.uk/git/cf.git","path":"Chunkytext", "subservices":[
{"name":"foo","path":"foo"}
{"name":"Ceefax (East)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/East","path":"CeefaxEast", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":true}]},
{"name":"Ceefax (East Midlands)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/EastMidlands","path":"CeefaxEastMids", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":true}]},
{"name":"Ceefax (London)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/London","path":"CeefaxLondon", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":true}]},
{"name":"Ceefax (Northern Ireland)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/NorthernIreland","path":"CeefaxNI", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":true}]},
{"name":"Ceefax (Scotland)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/Scotland","path":"CeefaxScotland", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":true}]},
{"name":"Ceefax (South)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/South","path":"CeefaxSouth", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":true}]},
{"name":"Ceefax (South West)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/SouthWest","path":"CeefaxSouthWest", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":true}]},
{"name":"Ceefax (Wales)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/Wales","path":"CeefaxWales", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":true}]},
{"name":"Ceefax (West)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/West","path":"CeefaxWest", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":true}]},
{"name":"Ceefax (Worldwide)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/Worldwide","path":"CeefaxWorldwide", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":true}]},
{"name":"Ceefax (Yorks and Lincs)","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/Yorks&Lincs","path":"CeefaxYorksAndLincs", "subservices":[{"name":"CeefaxCommon","type":"svn","url":"https://internal.nathanmediaservices.co.uk/svn/ceefax/national","path":"National","required":true}]}
]},
{"name":"Chunkytext","type":"git","url":"https://zxnet.co.uk/git/cf.git","path":"Chunkytext"},
{"name":"SPARK","type":"git","url":"https://github.com/ZXGuesser/spark-teletext.git","path":"SPARK"}
]
}
8 changes: 4 additions & 4 deletions runvbit2.py → scripts/runvbit2.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def signalHandler(_signo, _stack_frame):

configData = config.load()

try:
service = config.getSelectedService(configData)
except Exception as e:
print(e)
service = config.getSelectedService()

if not service:
print("No service selected")
quit()

linesPerField = 16 # vbit2 defaults to 16 lpf
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions vbit-config.py → scripts/vbit-config.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import re
from dialog import Dialog

# get absolute path of vbit2 install
# get absolute path of vbit2 scripts directory
SCRIPTDIR = os.path.dirname(os.path.realpath(__file__))

# absolute path of known services file
Expand Down Expand Up @@ -279,7 +279,7 @@ def mainMenu():
subprocess.run(["systemctl", "--user", command, "vbit2.service"])
elif tag == "U":
os.system('clear')
subprocess.run(os.path.join(SCRIPTDIR,"update.sh")) # run the update script
subprocess.run(os.path.join(SCRIPTDIR,"../update.sh")) # run the update script
break # exit vbit-config

else:
Expand Down
2 changes: 1 addition & 1 deletion teletext-update.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Description=Automatically check active teletext service for updates

[Service]
Type=oneshot
ExecStart=%h/vbit2/teletext-update.sh
ExecStart=%h/.local/bin/teletext-update
2 changes: 1 addition & 1 deletion vbit2.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description=VBIT2

[Service]
Type=simple
ExecStart=%h/.local/bin/runvbit2.sh
ExecStart=%h/.local/bin/runvbit2
Restart=always

[Install]
Expand Down

0 comments on commit 9758fa7

Please sign in to comment.