{"action":"created","issue":{"url":"https://api.github.com/repos/couchbase/sync_gateway/issues/1739","repository_url":"https://api.github.com/repos/couchbase/sync_gateway","labels_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/1739/labels{/name}","comments_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/1739/comments","events_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/1739/events","html_url":"https://github.com/couchbase/sync_gateway/issues/1739","id":153106992,"number":1739,"title":"Removal of sync gateway 1.2 via package manager (dpkg) does not work if unsupported OS","user":{"login":"mattcarabine","id":5352963,"avatar_url":"https://avatars.githubusercontent.com/u/5352963?v=3","gravatar_id":"","url":"https://api.github.com/users/mattcarabine","html_url":"https://github.com/mattcarabine","followers_url":"https://api.github.com/users/mattcarabine/followers","following_url":"https://api.github.com/users/mattcarabine/following{/other_user}","gists_url":"https://api.github.com/users/mattcarabine/gists{/gist_id}","starred_url":"https://api.github.com/users/mattcarabine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattcarabine/subscriptions","organizations_url":"https://api.github.com/users/mattcarabine/orgs","repos_url":"https://api.github.com/users/mattcarabine/repos","events_url":"https://api.github.com/users/mattcarabine/events{/privacy}","received_events_url":"https://api.github.com/users/mattcarabine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-04T20:27:09Z","updated_at":"2016-05-04T22:15:24Z","closed_at":null,"body":"I tried to install Sync Gateway 1.2 via dpkg from the .deb file on the website.\r\n\r\nThe installation appears successful in terms of creating the correct directories etc but fails at creating the init script:\r\n\r\n```\r\nsudo dpkg -i couchbase-sync-gateway-enterprise_1.2.0-79_x86_64.deb \r\n[sudo] password for matt: \r\nSelecting previously unselected package couchbase-sync-gateway.\r\n(Reading database ... 146547 files and directories currently installed.)\r\nPreparing to unpack couchbase-sync-gateway-enterprise_1.2.0-79_x86_64.deb ...\r\nUnpacking couchbase-sync-gateway (1.2.0-79) ...\r\nSetting up couchbase-sync-gateway (1.2.0-79) ...\r\nERROR: unknown OS \"neon\"\r\nThis script creates an init service to run a sync_gateway instance.\r\nIf you want to install more than one service instance\r\ncreate additional services with different names.\r\n\r\nsync_gateway_service_install.sh\r\n    -h --help\r\n    --runas=<The user account to run sync_gateway as; default (sync_gateway)>\r\n    --runbase=<The directory to run sync_gateway from; defaut (/home/sync_gateway)>\r\n    --sgpath=<The path to the sync_gateway executable; default (/opt/couchbase-sync-gateway/bin/sync_gateway)>\r\n    --cfgpath=<The path to the sync_gateway JSON config file; default (/home/sync_gateway/sync_gateway.json)>\r\n    --logsdir=<The path to the log file direcotry; default (/home/sync_gateway/logs)>\r\n\r\ndpkg: error processing package couchbase-sync-gateway (--install):\r\n subprocess installed post-installation script returned error exit status 1\r\nErrors were encountered while processing:\r\n couchbase-sync-gateway\r\n```\r\n\r\nThis is not a big deal, I kind of expected this as I'm running KDE Neon (based on Ubuntu XenialXerus 16.04) which I know probably isn't supported.\r\nI seemed to be able to run sync_gateway properly by running the binary `sync_gateway` directly, but that's rather besides the point.\r\n\r\nAs I wanted to test the new `sgcollect_info` directly (via a source-based build) I decided to remove the `sync_gateway` package using `dpkg -r`, at which point I hit the following issue:\r\n\r\n```\r\n$ sudo dpkg -r couchbase-sync-gateway\r\n(Reading database ... 146916 files and directories currently installed.)\r\nRemoving couchbase-sync-gateway (1.2.0-79) ...\r\nERROR: unknown OS \"neon\"\r\nThis script removes an init service to run a sync_gateway instance.\r\ndpkg: error processing package couchbase-sync-gateway (--remove):\r\n subprocess installed pre-removal script returned error exit status 1\r\nErrors were encountered while processing:\r\n couchbase-sync-gateway\r\n```\r\n\r\nObviously at this point the sync_gateway files are still there (I assumed that it would run in reverse from the install script, shut down the sync_gateway instance safely first and then remove the files), and I can't seem to remove sync gateway through conventional means:\r\n\r\n```\r\n$ ls /opt/couchbase-sync-gateway \r\nbin  cbcollect_info  examples  LICENSE.txt  manifest.txt  README.txt  service  sg-check.py  tools  VERSION.txt\r\n```\r\n\r\nI checked the `/opt/couchbase-sync-gateway/service/sync_gateway_service_uninstall.sh` file to see why this was failing my removal. It seems that the script returns 1 (indicating failure) if it doesn't recognise the OS.\r\n\r\nThis seems really unusual to me as you should be able to make the assumption that if the user has installed on an unsupported OS then they will not have been able to install the service start script in the first place, hence they should not need it removed.\r\n\r\nMaking the following change to `sync_gateway_service_uninstall.sh` allowed my `dpkg -r` to correctly remove sync gateway from my machine.\r\n\r\n```\r\n        echo \"ERROR: unknown OS \\\"$OS\\\"\"\r\n        usage\r\n-       exit 1\r\n+       exit 0\r\n```\r\n\r\nExample of output on removal:\r\n\r\n```\r\nsudo dpkg -r couchbase-sync-gateway                                  \r\n(Reading database ... 146916 files and directories currently installed.)\r\nRemoving couchbase-sync-gateway (1.2.0-79) ...\r\nERROR: unknown OS \"neon\"\r\nThis script removes an init service to run a sync_gateway instance.\r\n```\r\n\r\nI am happy to contribute a patch to fix this issue if you think that it's appropriate, I understand if you would prefer slightly different behaviour in this edge-case.\r\nPlease let me know if you would like me to fix it in a certain manner or if you would rather one of the sync gateway team makes this fix themselves!"},"comment":{"url":"https://api.github.com/repos/couchbase/sync_gateway/issues/comments/217020150","html_url":"https://github.com/couchbase/sync_gateway/issues/1739#issuecomment-217020150","issue_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/1739","id":217020150,"user":{"login":"mattcarabine","id":5352963,"avatar_url":"https://avatars.githubusercontent.com/u/5352963?v=3","gravatar_id":"","url":"https://api.github.com/users/mattcarabine","html_url":"https://github.com/mattcarabine","followers_url":"https://api.github.com/users/mattcarabine/followers","following_url":"https://api.github.com/users/mattcarabine/following{/other_user}","gists_url":"https://api.github.com/users/mattcarabine/gists{/gist_id}","starred_url":"https://api.github.com/users/mattcarabine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattcarabine/subscriptions","organizations_url":"https://api.github.com/users/mattcarabine/orgs","repos_url":"https://api.github.com/users/mattcarabine/repos","events_url":"https://api.github.com/users/mattcarabine/events{/privacy}","received_events_url":"https://api.github.com/users/mattcarabine/received_events","type":"User","site_admin":false},"created_at":"2016-05-04T22:15:24Z","updated_at":"2016-05-04T22:15:24Z","body":"Sorry, this issue is not related to `sgcollect_info`, just an issue that I ran into when trying to get a set up for it.\r\n\r\nThe current title doesn't make any reference to `sgcollect_info`, please let me know what you think a more suitable title would be for prioritisation purposes, should I add the prefix `Installer:`?"}}