Skip to content

Instantly share code, notes, and snippets.

@harishgonnabattula
Created November 7, 2016 07:43
Show Gist options
  • Save harishgonnabattula/1b255787a854e5734878fd5fbb579de7 to your computer and use it in GitHub Desktop.
Save harishgonnabattula/1b255787a854e5734878fd5fbb579de7 to your computer and use it in GitHub Desktop.
Shell scrip to create a Kitura project, install the dependencies and start the server. You can add dependencies in this file only and just run the script.
#Shell script to automate creation and build of Kitura server
echo "Enter name for project"
read project_name
export $project_name
#Begin
# Creation of Kitura application
mkdir $project_name
cd $project_name
swift package init --type executable
echo "import PackageDescription
let package = Package(
name: \"$project_name\",
dependencies: [
.Package(url: \"https://github.com/IBM-Swift/Kitura.git\", majorVersion: 1, minor: 0)
])" >Package.swift
echo "import Kitura
let router = Router()
router.get(\"/\") {
request, response, next in
response.send(\"Hello, World!\")
next()
}
Kitura.addHTTPServer(onPort: 8090, with: router)
Kitura.run()" > ./Sources/main.swift
swift build
echo ".build/debug/$project_name" > ./server.sh
sh server.sh
#End of command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment