Skip to content

Instantly share code, notes, and snippets.

@Efreak
Created November 25, 2016 20:40
Show Gist options
  • Save Efreak/50f18b896426ad958efbaa0e058cb3f7 to your computer and use it in GitHub Desktop.
Save Efreak/50f18b896426ad958efbaa0e058cb3f7 to your computer and use it in GitHub Desktop.
Start persistent WSL with services and byobu in background. To launch byobu with wsltty, use the command in wsl.bat, and replace /bin/bash with /usr/bin/byobu. Raw
'syntax
' - Run: http://ss64.com/vb/run.html or https://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.84).aspx
' - Sleep: http://ss64.com/vb/sleep.html or https://msdn.microsoft.com/en-us/library/6t81adfd(v=vs.84).aspx
'start hidden byobu in WSL. If you like playing with zsh modules so much that your prompt frequently takes a long time to load, you'll want this.
CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c byobu", 0, false
'give it a bit to finish starting. https://msdn.microsoft.com/en-us/library/6t81adfd(v=vs.84).aspx
WScript.Sleep(3000)
'Make sure your WSL session never dies. If you don't care about accidentally closing byobu
CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sleep Infinity""", 0, false
'detach the byobu session and close the command prompt.
'If you don't do this, your byobu session will be limited in size by the hidden command window started on line 6.
CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""tmux send \ byobu\ detach-client ENTER""",0,false
'update the package listings. Why not?
'formerly sent outside of byobu, now sent inside so it can be cancelled if you want to.
CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""tmux send \ sudo\ apt-get\ update ENTER""",0,false
' start maintentance services that WSL doesn't run.
'Clear cached sudo credentials
CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service sudo start""",0,false
'make sure the hostname is set. sudo errors are annoying.
CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service hostname.sh start""",0,false
'CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service dns-clean start""",0,false
'syslog broken, https://github.com/Microsoft/BashOnWindows/issues/534
'CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service rsyslog start""",0,false
'who needs uuidd?
'CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service uuidd start""",0,false
'you probably want this if you use a DE
'CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service dbus start""",0,false
'start services you actually want
'Used for sftp since it's fairly universal outside of windows... Disable privelege separation in /etc/ssh/sshd_config or it won't work.
CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service ssh start""",0,false
' "daemon to balance interrupts for SMP systems". Doesn't sound necessary.
'CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service irqbalance start""",0,false
' sets kernel variables. idk if these even works.
'CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service procps start""",0,false
'task scheduling
CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service cron start""",0,false
CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service atd start""",0,false
CreateObject ("Wscript.Shell").Run "C:\Windows\System32\bash.exe -c ""sudo service unattended-upgrades start""",0,false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment