{"componentChunkName":"component---node-modules-gatsby-theme-blog-core-src-templates-post-query-js","path":"/turn-diskstation-into-self-hosted-git-server/","result":{"data":{"site":{"siteMetadata":{"title":"one melo a day","social":[{"name":"twitter","url":"https://twitter.com/melo0187"},{"name":"github","url":"https://github.com/melo0187"}]}},"blogPost":{"__typename":"MdxBlogPost","id":"463055a3-2f1f-5867-afd2-a4366a50bb37","excerpt":"One of the things I almost instantly wanted to do after purchasing my DiskStation was to use it as a private Git server. I thought I was in…","body":"function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"layout\": \"post\",\n  \"title\": \"Turn your DiskStation into a self-hosted Git server\",\n  \"author\": \"melo\",\n  \"date\": \"2016-03-05T19:22:10.000Z\",\n  \"categories\": [\"DiskStation\", \"Git\", \"Technical\"],\n  \"slug\": \"turn-diskstation-into-self-hosted-git-server\",\n  \"draft\": false,\n  \"meta_title\": \"Turn your DiskStation into a self-hosted Git server\"\n};\n\nvar makeShortcode = function makeShortcode(name) {\n  return function MDXDefaultShortcode(props) {\n    console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\");\n    return mdx(\"div\", props);\n  };\n};\n\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, [\"components\"]);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"One of the things I almost instantly wanted to do after purchasing my DiskStation was to use it as a private Git server.\\xA0I thought I was in luck when I saw that Synology offers a DSM package for Git, but\\xA0it turned out this\\xA0is too basic for my taste. The good thing is, since I now have \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://melo.myds.me/wordpress/lets-encrypt-for-tomcat-7-on-ds/\"\n  }), \"HTTPS accessible Tomcat\\xA0running on my DiskStation\"), \"\\xA0I can easily install and run\\xA0GitBlit. So let\\u2019s turn our DiskStation into\\xA0a private, HTTPS accessible, collaboration friendly Git server!\"), mdx(\"h2\", {\n    \"id\": \"the-motivation\"\n  }, \"The Motivation\"), mdx(\"p\", null, \"You might ask yourself: \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"\\u201CWhy\\xA0not just use\\xA0Synolog\\u2019s Git Package for DSM?\\u201D\"), \" Well, if you are the only one interacting with your\\xA0repositories, you are fine with ssh accessing your DiskStation every time you want to create a new repository and like to create shared, bare repositories manually on the command line,\\xA0feel free to do so. The best guide I could find for that is \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://www.sbprojects.com/knowledge/internetwork/synologygit/index.php\"\n  }), \"this one\"), \". However, I did not like this solution for several\\xA0reasons. I do want to collaborate on my repositories and I do want to be able to do so without creating full\\xA0DSM accounts for every collaborator. I do want to have a GUI both for creating and managing access to my repositories\\xA0instead of\\xA0ssh accessing my DiskStation, manually creating the repository and fiddle with file and folder permissions.\"), mdx(\"h2\", {\n    \"id\": \"my-way-to-go\"\n  }, \"My Way to go\"), mdx(\"p\", null, \"So I started to look around and found there are several solutions out there. If you are interested you can check out this comparison of \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://www.slant.co/topics/1440/~self-hosted-web-based-git-repository-managers\"\n  }), \"self-hosted web-based Git repository\\xA0managers\"), \". Although \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://about.gitlab.com/\"\n  }), \"GitLab\"), \" looks like a really good and very popular choice I decided otherwise. Main reason being that the \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://about.gitlab.com/installation/\"\n  }), \"documented installation methods\"), \" did not really spark any hope that I could get this to run on my DiskStation. \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://gitblit.com/\"\n  }), \"GitBlit\"), \"\\xA0however looked like an easy deployment of the GitBlit WAR file\\xA0to Tomcat. It also offers all the features I was looking for. It\\xA0provides me with a GUI to create repositories\\xA0and\\xA0manage access to them. This way\\xA0my repositories are both private and accessible. So now that you know why I chose GitBlit, read on to see how I managed to set it up and run it on my DiskStation. If you want to follow along, make sure you have Tomcat 7 already running on your DiskStation. In \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://melo.myds.me/wordpress/lets-encrypt-for-tomcat-7-on-ds/\"\n  }), \"my last post\"), \" I described how to use a Let\\u2019s Encrypt certificate to enable HTTPS for your Tomcat server and linked to a guide\\xA0I\\xA0partially used to setup Tomcat on the DiskStation, so make sure to check it out.\"), mdx(\"h2\", {\n    \"id\": \"set-up-gitblit\"\n  }, \"Set up GitBlit\"), mdx(\"p\", null, \"Obviously the first thing you want to do is to download\\xA0the latest GitBlit WAR file from the \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://gitblit.com/\"\n  }), \"official website\"), \". At this point you could just drop this WAR file into the Tomcat folder on your DiskStation, wait a few seconds for Tomcat to finish the deployment and access GitBlit by URL, which should look something like this (assuming you followed my last post):  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"https://yourDomain:8443/gitblit\"), \"  However there are a few tweaks that will ensure that all your repositories and settings will be persistent across GitBlit redeploys and updates and that all features are working properly. First thing is to set a custom GitBlit baseFolder as Tomcat Context to externalize GitBlit data from its deployment path both for safety and persistence across updates and redeploys as described in the \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://gitblit.com/setup_war.html\"\n  }), \"GitBlit WAR installation and setup guide\"), \". So access your DiksStation through ssh as root and edit Tomcat\\u2019s \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"context.xml\"), \" file. You can use vi to edit the file. The command should be similar to this one:  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"vi /volume1/@appstore/Tomcat/src/conf/context.xml\"), \"  Inside \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"context.xml\"), \" file you insert an \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"Environment\"), \" node within the \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"Context\"), \" node that looks like this:  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"<Environment name=\\\"baseFolder\\\" type=\\\"java.lang.String\\\" value=\\\"/volume1/@appstore/gitblit\\\" />\"), \"  If you deploy the GitBlit WAR now, all the configuration files and repositories will go inside the baseFolder you just specified. To ensure all GitBlit generated URLs will work you need to do three\\xA0things. First add \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"org.apache.tomcat.util.buf.UDecoder.ALLOW\", \"_\", \"ENCODED\", \"_\", \"SLASH=true\"), \" to\\xA0\", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"CATALINA\", \"_\", \"OPTS\"), \". To accomplish this I edited\\xA0the \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"setenv.sh\"), \" file located in\\xA0 \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"/volume1/@appstore/Tomcat7/src/bin/\"), \" .\\xA0Add the following line to it:  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"CATALINA_OPTS=-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true\"), \"  Second ensure your Tomcat connector configuration uses the UTF-8 encoding (which it does if you followed my last post). Check\\xA0the \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://gitblit.com/faq.html#H10\"\n  }), \"GitBlit FAQ\"), \" for these two steps. Third\\xA0add\\xA0\", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"web.canonicalName\"), \" to \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://gitblit.com/properties.html\"\n  }), \"gitblit.Properties\"), \" - which you can find in the baseFolder you specified earlier - and set it to the URL you use to access GitBlit. It is noteworthy that GitBlit comes with a \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://gitblit.com/tickets_overview.html\"\n  }), \"tickets feature\"), \", which is analogous to GitHub/BitBucket Issues+Pull Requests. However this feature is disabled by default and the main reason is that you must choose the persistence backend to use for the tickets. You can choose between persisting to files, branch or to a Redis data store. Check out the \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://gitblit.com/tickets_setup.html\"\n  }), \"documentation\"), \" to make an informed decision. I decided to use the branch ticket service, so I added the following line to \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"gitblit.properties\"), \":  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"tickets.service = com.gitblit.tickets.BranchTicketService\"), \"  At this point I thought I was done, but when starting GitBlit and looking at the Tomcat log I noticed that GitBlit failed to start its git and ssh daemon on my DiskStation, because the ports were already in use. If this is the case for you too, You can easily fix this by adding\\xA0the settings \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"git.daemonPort\"), \" and \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"git.sshPort\"), \"\\xA0to your \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"gitblit.Properties\"), \" file inside your basefolder and provide non-default port numbers, to allow GitBlit to run these services. Don\\u2019t forget\\xA0to setup \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://www.synology.com/en-global/knowledgebase/DSM/help/DSM/AdminCenter/connection_routerconf\"\n  }), \"port forwarding\"), \" and an according \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://www.synology.com/en-global/knowledgebase/DSM/help/DSM/AdminCenter/connection_security_firewall\"\n  }), \"firewall rule\"), \" for\\xA0the configured \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"git.sshPort\"), \"\\xA0to allow usage of the ssh protocol\\xA0for interaction with your repositories. Now you are finally done! After restarting Tomcat (e.g. with the DSM Package Center) the new settings for Tomcat and GitBlit are applied and you can access your very own GitBlit server using an URL like\\xA0 \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"https://yourDomain:8443/gitblit\"), \" . \\xA0It is available through HTTPS, just like your Tomcat server is, without the need to configure anything HTTPS related in GitBlit itself. GitBlit will now produce working URLs to interact with your repositories and store everything safely in the defined baseFolder. In my case this is  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"/volume1/@appstore/gitblit\"), \" , which is persistent even across DSM updates, so there won\\u2019t be\\xA0anything gone missing after you update GitBlit or your DiskStation\\u2019s DSM version. So log in with\\xA0 the default administrator credentials\\xA0\", mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"admin / admin\"), \"\\xA0and change your admin password, create repositories, set their access policy, create users for collaborators, grant them\\xA0access to specific repositories and enjoy all of this on your very own self-hosted Git\\xA0server!\"), mdx(\"h2\", {\n    \"id\": \"the-icing-on-the-cake\"\n  }, \"The icing on the cake\"), mdx(\"p\", null, \"In case you plan to deploy further applications on Tomcat, I ask you: Wouldn\\u2019t it be nice if you could use the same credentials instead of creating a new user for every application you deploy? By default GitBlit uses a simple \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"users.conf\"), \" file to store user information inside its baseFolder. But If you want to take this a little step further, instead of using GitBlit\\u2019s own \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"users.conf\"), \" file you can configure GitBlit to use the LDAP authentication provider and\\xA0thus connect GitBlit to a\\xA0directory server to\\xA0handle user authentication.\\xA0What lucky coincidence that Synology\\u2019s Package Center\\xA0offers a \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://www.synology.com/en-us/dsm/app_packages/DirectoryServer\"\n  }), \"Directory Server package\"), \", right? So I hope this was interesting to you and recommend you check back\\xA0for my next post to find out how to setup Synology Directory Server and connect GitBlit to it!\"));\n}\n;\nMDXContent.isMDXComponent = true;","slug":"/turn-diskstation-into-self-hosted-git-server/","title":"Turn your DiskStation into a self-hosted Git server","tags":[],"keywords":[],"date":"March 05, 2016"},"previous":{"__typename":"MdxBlogPost","id":"703f4203-112a-57c0-9975-ecd2b70d909c","excerpt":"In my  last blog post  I described the benefits of HTTPS and how to set up your Synology DiskStation to use HTTPS with a trusted certificate…","slug":"/lets-encrypt-for-tomcat-7-on-ds/","title":"HTTPS for Tomcat 7 with Let's Encrypt","date":"February 13, 2016"},"next":{"__typename":"MdxBlogPost","id":"8f0f5fc1-5dd6-5002-b985-3c2581046db9","excerpt":"My experience upgrading a DS214play from DSM 5.2 to 6.0","slug":"/explosive-dsm-6-update/","title":"DSM 6 Adventures: Explosive Update","date":"March 31, 2016"}},"pageContext":{"isCreatedByStatefulCreatePages":false,"id":"463055a3-2f1f-5867-afd2-a4366a50bb37","previousId":"703f4203-112a-57c0-9975-ecd2b70d909c","nextId":"8f0f5fc1-5dd6-5002-b985-3c2581046db9"}}}