{"action":"created","comment":{"url":"https://api.github.com/repos/influxdb/influxdb/pulls/comments/33302716","id":33302716,"diff_hunk":"@@ -20,24 +20,46 @@\n \n # Command-line options that can be set in /etc/default/influxdb.  These will override\n # any config file values. Example: \"-join http://1.2.3.4:8086\"\n+DEFAULT=/etc/default/influxdb\n+\n+# Daemon options\n INFLUXD_OPTS=\n \n+# Process name ( For display )\n+NAME=influxdb\n+\n+# User and group\n USER=influxdb\n GROUP=influxdb\n \n-if [ -r /lib/lsb/init-functions ]; then\n-    source /lib/lsb/init-functions\n+# Daemon name, where is the actual executable\n+# If the daemon is not there, then exit.\n+DAEMON=/opt/influxdb/influxd\n+[ -x $DAEMON ] || exit 5\n+\n+# Configuration file\n+CONFIG=/etc/opt/influxdb/influxdb.conf\n+\n+# PID file for the daemon\n+PIDFILE=/var/run/influxdb/influxd.pid\n+PIDDIR=`dirname $PIDFILE`\n+if [ ! -d \"$PIDDIR\" ]; then\n+    mkdir -p $PIDDIR\n+    chown $GROUP:$USER $PIDDIR\n fi\n \n-DEFAULT=/etc/default/influxdb\n+# Max open files\n+OPEN_FILE_LIMIT=65536\n \n-if [ -r $DEFAULT ]; then\n-    source $DEFAULT\n+if [ -r /lib/lsb/init-functions ]; then","path":"scripts/init.sh","position":40,"original_position":40,"commit_id":"fa1cca30784f96a7a9e65fd6a2c7ba1af3d242cc","original_commit_id":"fa1cca30784f96a7a9e65fd6a2c7ba1af3d242cc","user":{"login":"otoolep","id":536312,"avatar_url":"https://avatars.githubusercontent.com/u/536312?v=3","gravatar_id":"","url":"https://api.github.com/users/otoolep","html_url":"https://github.com/otoolep","followers_url":"https://api.github.com/users/otoolep/followers","following_url":"https://api.github.com/users/otoolep/following{/other_user}","gists_url":"https://api.github.com/users/otoolep/gists{/gist_id}","starred_url":"https://api.github.com/users/otoolep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otoolep/subscriptions","organizations_url":"https://api.github.com/users/otoolep/orgs","repos_url":"https://api.github.com/users/otoolep/repos","events_url":"https://api.github.com/users/otoolep/events{/privacy}","received_events_url":"https://api.github.com/users/otoolep/received_events","type":"User","site_admin":false},"body":"OK, the diff is confused, it's not a change.","created_at":"2015-06-25T20:43:23Z","updated_at":"2015-06-25T20:43:23Z","html_url":"https://github.com/influxdb/influxdb/pull/3115#discussion_r33302716","pull_request_url":"https://api.github.com/repos/influxdb/influxdb/pulls/3115","_links":{"self":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/comments/33302716"},"html":{"href":"https://github.com/influxdb/influxdb/pull/3115#discussion_r33302716"},"pull_request":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/3115"}}},"pull_request":{"url":"https://api.github.com/repos/influxdb/influxdb/pulls/3115","id":38395688,"html_url":"https://github.com/influxdb/influxdb/pull/3115","diff_url":"https://github.com/influxdb/influxdb/pull/3115.diff","patch_url":"https://github.com/influxdb/influxdb/pull/3115.patch","issue_url":"https://api.github.com/repos/influxdb/influxdb/issues/3115","number":3115,"state":"open","locked":false,"title":"init.d script improvements","user":{"login":"KoeSystems","id":4624589,"avatar_url":"https://avatars.githubusercontent.com/u/4624589?v=3","gravatar_id":"","url":"https://api.github.com/users/KoeSystems","html_url":"https://github.com/KoeSystems","followers_url":"https://api.github.com/users/KoeSystems/followers","following_url":"https://api.github.com/users/KoeSystems/following{/other_user}","gists_url":"https://api.github.com/users/KoeSystems/gists{/gist_id}","starred_url":"https://api.github.com/users/KoeSystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KoeSystems/subscriptions","organizations_url":"https://api.github.com/users/KoeSystems/orgs","repos_url":"https://api.github.com/users/KoeSystems/repos","events_url":"https://api.github.com/users/KoeSystems/events{/privacy}","received_events_url":"https://api.github.com/users/KoeSystems/received_events","type":"User","site_admin":false},"body":"# Objectives\r\n1. Clarify script changing variables to capital letter.\r\n2. Allow to overwrite all the variables with default variables.\r\n3. Check if config file exists and it's readable.\r\n4. Check if pidfile is writable.\r\n\r\n# Motivation\r\n1. The current init script use lower case for some variables which names match with the output messages, changing this variables to capital letter makes the script more standard and more readable.\r\n2. The current init script does not allow the overwrite of all the variables with environment variables, this would make that some users need to change the init script (instead of add environment variables or edit /etc/default/influxdb) or would make harder to manage influxdb from automatisation systems like puppet.\r\n3. The config file exists by default ( built from package.sh ), however could exist a race condition in some environments, better if we check if config file exists.\r\n4. Like point 3, some race condition could happen, better if we check if pidfile is writable.\r\n\r\n# Changes\r\n1. Change all the variables in lower case by capital letter.\r\n2. Move the definition of the variables before load the $DEFAULT file\r\n3. Check if config file is readable, if not exit 4.\r\n4. If the pidfile doesn't exists, check if writable doing a touch with the proper user, exit 5 if it fails.\r\n\r\n# Backward compatibility\r\nNo changes in the way influxDB is launched neither how the init script is called neither in the value of default variables, so it's full backward compatible.\r\n\r\n# Testing\r\nI didn't find integration test over the builded package and the [CI test](https://github.com/influxdb/influxdb/blob/master/circle-test.sh) seems to test \"only\" the code, not the init script.\r\n\r\nFor this reason I run some manual test:\r\n* with empty /etc/default/influxdb\r\n\r\n```\r\nroot@vm01:~# service influxdb version \r\nInfluxDB v0.9.0 (git: .... )\r\n\r\nroot@vm01:~# service influxdb status\r\ninfluxdb Process is not running [ FAILED ]\r\n\r\nroot@vm01:~# service influxdb start\r\nStarting the process influxdb [ OK ]\r\ninfluxdb process was started [ OK ]\r\n\r\nroot@vm01:~# service influxdb start\r\ninfluxdb process is running [ FAILED ]\r\n\r\nroot@vm01:~# service influxdb stop\r\ninfluxdb process was stopped [ OK ]\r\n\r\nroot@vm01:~# service influxdb stop\r\ninfluxdb process is not running [ FAILED ]\r\n\r\n```\r\n\r\nwith some config in /etc/default/influxdb\r\n\r\n```\r\nroot@vm01:~# cat /etc/default/influxdb \r\nCONFIG=/opt/influxdb/etc/influxdb.conf\r\n\r\nroot@vm01:~# service influxdb start\r\nconfig file doesn't exists [ FAILED ]\r\n```\r\n\r\n```\r\nroot@vm01:~# cat /etc/default/influxdb \r\nPIDFILE=/var/run/influxdb.pid\r\n\r\nroot@vm01:~# service influxdb start\r\n/var/run/influxdb.pid now writable, check permissions [ FAILED ]\r\n```\r\n\r\n```\r\nroot@vm01:~# cat /etc/default/influxdb\r\nCONFIG=/etc/opt/influxdb/influxdb.conf\r\nPIDFILE=/var/run/influxdb/influxdb.pid\r\n\r\nroot@vm01:~# service influxdb start\r\nStarting the process influxdb [ OK ]\r\ninfluxdb process was started [ OK ]\r\n```\r\n\r\n","created_at":"2015-06-23T23:58:54Z","updated_at":"2015-06-25T20:43:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3745289d58e586f018047b700cd2424ad3bfbc7d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/influxdb/influxdb/pulls/3115/commits","review_comments_url":"https://api.github.com/repos/influxdb/influxdb/pulls/3115/comments","review_comment_url":"https://api.github.com/repos/influxdb/influxdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/influxdb/influxdb/issues/3115/comments","statuses_url":"https://api.github.com/repos/influxdb/influxdb/statuses/fa1cca30784f96a7a9e65fd6a2c7ba1af3d242cc","head":{"label":"KoeSystems:init-script-improvements","ref":"init-script-improvements","sha":"fa1cca30784f96a7a9e65fd6a2c7ba1af3d242cc","user":{"login":"KoeSystems","id":4624589,"avatar_url":"https://avatars.githubusercontent.com/u/4624589?v=3","gravatar_id":"","url":"https://api.github.com/users/KoeSystems","html_url":"https://github.com/KoeSystems","followers_url":"https://api.github.com/users/KoeSystems/followers","following_url":"https://api.github.com/users/KoeSystems/following{/other_user}","gists_url":"https://api.github.com/users/KoeSystems/gists{/gist_id}","starred_url":"https://api.github.com/users/KoeSystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KoeSystems/subscriptions","organizations_url":"https://api.github.com/users/KoeSystems/orgs","repos_url":"https://api.github.com/users/KoeSystems/repos","events_url":"https://api.github.com/users/KoeSystems/events{/privacy}","received_events_url":"https://api.github.com/users/KoeSystems/received_events","type":"User","site_admin":false},"repo":{"id":37945188,"name":"influxdb","full_name":"KoeSystems/influxdb","owner":{"login":"KoeSystems","id":4624589,"avatar_url":"https://avatars.githubusercontent.com/u/4624589?v=3","gravatar_id":"","url":"https://api.github.com/users/KoeSystems","html_url":"https://github.com/KoeSystems","followers_url":"https://api.github.com/users/KoeSystems/followers","following_url":"https://api.github.com/users/KoeSystems/following{/other_user}","gists_url":"https://api.github.com/users/KoeSystems/gists{/gist_id}","starred_url":"https://api.github.com/users/KoeSystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KoeSystems/subscriptions","organizations_url":"https://api.github.com/users/KoeSystems/orgs","repos_url":"https://api.github.com/users/KoeSystems/repos","events_url":"https://api.github.com/users/KoeSystems/events{/privacy}","received_events_url":"https://api.github.com/users/KoeSystems/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KoeSystems/influxdb","description":"Scalable datastore for metrics, events, and real-time analytics","fork":true,"url":"https://api.github.com/repos/KoeSystems/influxdb","forks_url":"https://api.github.com/repos/KoeSystems/influxdb/forks","keys_url":"https://api.github.com/repos/KoeSystems/influxdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KoeSystems/influxdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KoeSystems/influxdb/teams","hooks_url":"https://api.github.com/repos/KoeSystems/influxdb/hooks","issue_events_url":"https://api.github.com/repos/KoeSystems/influxdb/issues/events{/number}","events_url":"https://api.github.com/repos/KoeSystems/influxdb/events","assignees_url":"https://api.github.com/repos/KoeSystems/influxdb/assignees{/user}","branches_url":"https://api.github.com/repos/KoeSystems/influxdb/branches{/branch}","tags_url":"https://api.github.com/repos/KoeSystems/influxdb/tags","blobs_url":"https://api.github.com/repos/KoeSystems/influxdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KoeSystems/influxdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KoeSystems/influxdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/KoeSystems/influxdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KoeSystems/influxdb/statuses/{sha}","languages_url":"https://api.github.com/repos/KoeSystems/influxdb/languages","stargazers_url":"https://api.github.com/repos/KoeSystems/influxdb/stargazers","contributors_url":"https://api.github.com/repos/KoeSystems/influxdb/contributors","subscribers_url":"https://api.github.com/repos/KoeSystems/influxdb/subscribers","subscription_url":"https://api.github.com/repos/KoeSystems/influxdb/subscription","commits_url":"https://api.github.com/repos/KoeSystems/influxdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/KoeSystems/influxdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/KoeSystems/influxdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/KoeSystems/influxdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/KoeSystems/influxdb/contents/{+path}","compare_url":"https://api.github.com/repos/KoeSystems/influxdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KoeSystems/influxdb/merges","archive_url":"https://api.github.com/repos/KoeSystems/influxdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KoeSystems/influxdb/downloads","issues_url":"https://api.github.com/repos/KoeSystems/influxdb/issues{/number}","pulls_url":"https://api.github.com/repos/KoeSystems/influxdb/pulls{/number}","milestones_url":"https://api.github.com/repos/KoeSystems/influxdb/milestones{/number}","notifications_url":"https://api.github.com/repos/KoeSystems/influxdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KoeSystems/influxdb/labels{/name}","releases_url":"https://api.github.com/repos/KoeSystems/influxdb/releases{/id}","created_at":"2015-06-23T21:09:07Z","updated_at":"2015-06-23T21:09:09Z","pushed_at":"2015-06-24T00:58:31Z","git_url":"git://github.com/KoeSystems/influxdb.git","ssh_url":"git@github.com:KoeSystems/influxdb.git","clone_url":"https://github.com/KoeSystems/influxdb.git","svn_url":"https://github.com/KoeSystems/influxdb","homepage":"http://influxdb.com","size":24023,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"influxdb:master","ref":"master","sha":"246ce61b85d3d7b1eb5da354c35e2c4b4b42020e","user":{"login":"influxdb","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdb","html_url":"https://github.com/influxdb","followers_url":"https://api.github.com/users/influxdb/followers","following_url":"https://api.github.com/users/influxdb/following{/other_user}","gists_url":"https://api.github.com/users/influxdb/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdb/subscriptions","organizations_url":"https://api.github.com/users/influxdb/orgs","repos_url":"https://api.github.com/users/influxdb/repos","events_url":"https://api.github.com/users/influxdb/events{/privacy}","received_events_url":"https://api.github.com/users/influxdb/received_events","type":"Organization","site_admin":false},"repo":{"id":13124802,"name":"influxdb","full_name":"influxdb/influxdb","owner":{"login":"influxdb","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdb","html_url":"https://github.com/influxdb","followers_url":"https://api.github.com/users/influxdb/followers","following_url":"https://api.github.com/users/influxdb/following{/other_user}","gists_url":"https://api.github.com/users/influxdb/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdb/subscriptions","organizations_url":"https://api.github.com/users/influxdb/orgs","repos_url":"https://api.github.com/users/influxdb/repos","events_url":"https://api.github.com/users/influxdb/events{/privacy}","received_events_url":"https://api.github.com/users/influxdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/influxdb/influxdb","description":"Scalable datastore for metrics, events, and real-time analytics","fork":false,"url":"https://api.github.com/repos/influxdb/influxdb","forks_url":"https://api.github.com/repos/influxdb/influxdb/forks","keys_url":"https://api.github.com/repos/influxdb/influxdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdb/influxdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdb/influxdb/teams","hooks_url":"https://api.github.com/repos/influxdb/influxdb/hooks","issue_events_url":"https://api.github.com/repos/influxdb/influxdb/issues/events{/number}","events_url":"https://api.github.com/repos/influxdb/influxdb/events","assignees_url":"https://api.github.com/repos/influxdb/influxdb/assignees{/user}","branches_url":"https://api.github.com/repos/influxdb/influxdb/branches{/branch}","tags_url":"https://api.github.com/repos/influxdb/influxdb/tags","blobs_url":"https://api.github.com/repos/influxdb/influxdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdb/influxdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdb/influxdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdb/influxdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdb/influxdb/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdb/influxdb/languages","stargazers_url":"https://api.github.com/repos/influxdb/influxdb/stargazers","contributors_url":"https://api.github.com/repos/influxdb/influxdb/contributors","subscribers_url":"https://api.github.com/repos/influxdb/influxdb/subscribers","subscription_url":"https://api.github.com/repos/influxdb/influxdb/subscription","commits_url":"https://api.github.com/repos/influxdb/influxdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdb/influxdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdb/influxdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdb/influxdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdb/influxdb/contents/{+path}","compare_url":"https://api.github.com/repos/influxdb/influxdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdb/influxdb/merges","archive_url":"https://api.github.com/repos/influxdb/influxdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdb/influxdb/downloads","issues_url":"https://api.github.com/repos/influxdb/influxdb/issues{/number}","pulls_url":"https://api.github.com/repos/influxdb/influxdb/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdb/influxdb/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdb/influxdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdb/influxdb/labels{/name}","releases_url":"https://api.github.com/repos/influxdb/influxdb/releases{/id}","created_at":"2013-09-26T14:31:10Z","updated_at":"2015-06-25T14:21:43Z","pushed_at":"2015-06-25T20:42:41Z","git_url":"git://github.com/influxdb/influxdb.git","ssh_url":"git@github.com:influxdb/influxdb.git","clone_url":"https://github.com/influxdb/influxdb.git","svn_url":"https://github.com/influxdb/influxdb","homepage":"http://influxdb.com","size":49716,"stargazers_count":5680,"watchers_count":5680,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":555,"mirror_url":null,"open_issues_count":284,"forks":555,"open_issues":284,"watchers":5680,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/3115"},"html":{"href":"https://github.com/influxdb/influxdb/pull/3115"},"issue":{"href":"https://api.github.com/repos/influxdb/influxdb/issues/3115"},"comments":{"href":"https://api.github.com/repos/influxdb/influxdb/issues/3115/comments"},"review_comments":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/3115/comments"},"review_comment":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/3115/commits"},"statuses":{"href":"https://api.github.com/repos/influxdb/influxdb/statuses/fa1cca30784f96a7a9e65fd6a2c7ba1af3d242cc"}}}}