@@ 1,6 1,8 @@
changelog
-### next
+### 1.4.1 Antiquated Automaton
+
++ Add back a scriptable init function.
+ Document that go 1.20+ is now required.
@@ 10,7 10,7 @@ require (
golang.org/x/net v0.28.0
humungus.tedunangst.com/r/go-sqlite3 v1.2.1
humungus.tedunangst.com/r/gonix v0.1.4
- humungus.tedunangst.com/r/termvc v0.1.2
+ humungus.tedunangst.com/r/termvc v0.1.3
humungus.tedunangst.com/r/webs v0.7.18
)
@@ 78,7 78,7 @@ humungus.tedunangst.com/r/go-sqlite3 v1.
humungus.tedunangst.com/r/go-sqlite3 v1.2.1/go.mod h1:YrRIH0O7uePPLbJriXrER44ym5aQ0QxK8CnaT/GWOkg=
humungus.tedunangst.com/r/gonix v0.1.4 h1:FuvWYQlFIzmfHxfvIfq5SYpSiHhFcpJqq3pi+w45s78=
humungus.tedunangst.com/r/gonix v0.1.4/go.mod h1:VFBc2bPDXr1ayHOmHUutxYu8fSM+pkwK8o36h4rkORg=
-humungus.tedunangst.com/r/termvc v0.1.2 h1:TPH5ThFRjR+f1ko9Uh4dhm3ieNKvmoPZAvu3tU5lNIE=
-humungus.tedunangst.com/r/termvc v0.1.2/go.mod h1:TnlG9PbH77OpEf46iDyb/H9drjegQNwhpXalmGGrbhU=
+humungus.tedunangst.com/r/termvc v0.1.3 h1:BYxcqdA2Ijhqolf2BdNlGw5355qE80EzAqiNgi7d5tk=
+humungus.tedunangst.com/r/termvc v0.1.3/go.mod h1:TnlG9PbH77OpEf46iDyb/H9drjegQNwhpXalmGGrbhU=
humungus.tedunangst.com/r/webs v0.7.18 h1:tCPZuC7p/8chlOSb1RBJYxnGauBg2Lzm5DO4cu+82HI=
humungus.tedunangst.com/r/webs v0.7.18/go.mod h1:ylhqHSPI0Oi7b4nsnx5mSO7AjLXN7wFpEHayLfN/ugk=
@@ 16,6 16,7 @@
package main
import (
+ "bufio"
"crypto/rand"
"crypto/rsa"
"database/sql"
@@ 77,14 78,27 @@ func initdb() {
prepareStatements(db)
+ setcsrfkey()
+ setconfig("dbversion", myVersion)
+
+ setconfig("servermsg", "<h2>Things happen.</h2>")
+ setconfig("aboutmsg", "<h3>What is honk?</h3><p>Honk is amazing!")
+ setconfig("loginmsg", "<h2>login</h2>")
+ setconfig("devel", 0)
+
cleanup := func() {
os.Remove(dbname)
os.Remove(blobdbname)
os.Exit(1)
}
+ defer cleanup()
+
+ if !termvc.IsTerm() {
+ simplesetup(db)
+ return
+ }
termvc.Start()
- defer cleanup()
defer termvc.Restore()
go termvc.Catch(cleanup)
@@ 147,16 161,58 @@ func initdb() {
return
}
- setcsrfkey()
- setconfig("dbversion", myVersion)
+ db.Close()
+ termvc.Restore()
+ fmt.Printf("done.\n")
+ os.Exit(0)
+}
- setconfig("servermsg", "<h2>Things happen.</h2>")
- setconfig("aboutmsg", "<h3>What is honk?</h3><p>Honk is amazing!")
- setconfig("loginmsg", "<h2>login</h2>")
- setconfig("devel", 0)
+func simplesetup(db *sql.DB) {
+ r := bufio.NewReader(os.Stdin)
+ fmt.Printf("username: ")
+ name, err := r.ReadString('\n')
+ name = name[:len(name)-1]
+ fmt.Printf("password: ")
+ pass, err := r.ReadString('\n')
+ pass = pass[:len(pass)-1]
+ err = createuser(db, name, pass)
+ if err != nil {
+ elog.Print(err)
+ return
+ }
+ // must came later or user above will have negative id
+ err = createserveruser(db)
+ if err != nil {
+ elog.Print(err)
+ return
+ }
+
+ fmt.Printf("listen address: ")
+ addr, err := r.ReadString('\n')
+ if err != nil {
+ elog.Print(err)
+ return
+ }
+ addr = addr[:len(addr)-1]
+ if len(addr) < 1 {
+ elog.Print("that's way too short")
+ return
+ }
+ setconfig("listenaddr", addr)
+ fmt.Printf("server name: ")
+ addr, err = r.ReadString('\n')
+ if err != nil {
+ elog.Print(err)
+ return
+ }
+ addr = addr[:len(addr)-1]
+ if len(addr) < 1 {
+ elog.Print("that's way too short")
+ return
+ }
+ setconfig("servername", addr)
db.Close()
- termvc.Restore()
fmt.Printf("done.\n")
os.Exit(0)
}