Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Won't run as deamon. #1985

Closed
eangulus opened this issue Nov 4, 2014 · 19 comments
Closed

Won't run as deamon. #1985

eangulus opened this issue Nov 4, 2014 · 19 comments
Labels

Comments

@eangulus
Copy link

eangulus commented Nov 4, 2014

Have headphones setup from git on Ubuntu 12.10.

Works fine when started using python headphones.py

I tried following the instructions for installing deamon and they are wrong in the Wiki. At one point it says to create a symbolic link of the init.ubuntu file, then the next part to set permissions for the /etc/init.d/headphones symbolic link, fails.

Will only let me set permissions if I copy the the file over instead.

Either way I try starting as daemon and it says it started, but no process or error or anything.

I have followed the wiki to the letter (barring the symlink, instead copying in full over), I have double checked my paths and also double checked the permissions.

Again, works fine if I start using python headphones.py, but not as deamon.

@basilfx
Copy link
Contributor

basilfx commented Nov 4, 2014

If you copy it or make a symbolic link: it doesn't matter. The only thing is, if init.ubuntu changes, it will be updated automatically.

Make sure you check the comments in the init file. You probably forgot to create the /etc/default/headphones file with the contents suggested here

@eangulus
Copy link
Author

eangulus commented Nov 4, 2014

As clearly stated before, I followed the Official Wiki instructions (https://github.com/rembo10/headphones/wiki/Install-as-a-daemon) to the letter, which includes making the changes to the /etc/default/headphones file.

But if I do:

sudo ln -s ./init-scripts/init.ubuntu /etc/init.d/headphones

then:

sudo update-rc.d headphones defaults

doesn't work.

So the only change I made is I copied the file over.

Also note the it is definitely reading my defaults file, as if I enter wrong values there, it gives me errors. Once the correct ones are in I get no errors. I am told it started, then when I check it isn't running and there is no running process either. The ONLY way so far for me to run it is by using the python headphones.py line.

@basilfx
Copy link
Contributor

basilfx commented Nov 5, 2014

I have updated the troubleshooting wiki and elaborated on debugging this problem. Could you check/test it out for me? You can find it here

Note that this issue can be hard to debug, even tough a small mistake can cause the problem. I think your problem is related to permissions: the normal way of starting runs under user A while, the daemon way of starting runs under user B. B cannot access/change files created by A.

@eangulus
Copy link
Author

eangulus commented Nov 5, 2014

Makes sense. But firstly I have done this a number of times before, and knowing all about even little things, I have tried different things to try and fix.

I have tried as normal user and even as root (including changing permissions to suit).

I'll try out that link and let you know how I go.

Would be much easier if it just did a log file or something so I may be able to see what is happening when attempting to start it.

@basilfx
Copy link
Contributor

basilfx commented Nov 5, 2014

It does write to a log file, if it can create one. If you change the init script to not deamonize and add verbose, it should show you what is going on.

@eangulus
Copy link
Author

eangulus commented Nov 5, 2014

THis is the result after adding verbose.

 * Removing stale /var/run/headphones/headphones.pid
 * Starting Headphones
05-Nov-2014 13:55:42 - INFO :: MainThread : Checking to see if the database has all tables....
05-Nov-2014 13:55:42 - DEBUG :: MainThread : Trying to execute: "git rev-parse HEAD" with shell in /home/karen/.headphones
05-Nov-2014 13:55:42 - DEBUG :: MainThread : Git output: 6b4fbe002d481c5b6d421bccaea79c183bb272b0
05-Nov-2014 13:55:42 - DEBUG :: MainThread : Trying to execute: "git rev-parse --abbrev-ref HEAD" with shell in /home/karen/.headphones
05-Nov-2014 13:55:42 - DEBUG :: MainThread : Git output: master
05-Nov-2014 13:55:42 - INFO :: MainThread : Retrieving latest version information from GitHub
05-Nov-2014 13:55:42 - DEBUG :: MainThread : Requesting URL via GET method: https://api.github.com/repos/rembo10/headphones/commits/master
05-Nov-2014 13:55:43 - DEBUG :: MainThread : Latest version is 6b4fbe002d481c5b6d421bccaea79c183bb272b0
05-Nov-2014 13:55:43 - INFO :: MainThread : Headphones is up to date
05-Nov-2014 13:55:43 - DEBUG :: MainThread : Using the following server values: MBHost: 144.76.94.239, MBPort: 8181, Sleep Interval: 0
05-Nov-2014 13:55:43 - INFO :: MainThread : Starting Headphones web server on http://http://gbqynekzsvdy.com/:8181/
05-Nov-2014 13:55:43 - ERROR :: HTTPServer Thread-1 : Uncaught exception: Traceback (most recent call last):
  File "/home/karen/.headphones/headphones/logger.py", line 204, in new_run
    old_run(*args, **kwargs)
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "lib/cherrypy/process/servers.py", line 187, in _start_http_thread
    self.httpserver.start()
  File "lib/cherrypy/wsgiserver/wsgiserver2.py", line 1824, in start
    raise socket.error(msg)
error: No socket could be created

Traceback (most recent call last):
  File "/home/karen/.headphones/headphones/logger.py", line 204, in new_run
    old_run(*args, **kwargs)
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "lib/cherrypy/process/servers.py", line 187, in _start_http_thread
    self.httpserver.start()
  File "lib/cherrypy/wsgiserver/wsgiserver2.py", line 1824, in start
    raise socket.error(msg)
socket.error: No socket could be created
Failed to start on port: 8181. Is something else running?
   ...fail!

Now, weird part is that nothing else is running on 8181. Closest there is is Apache on port 80 with a port forwarding on router as 81 to the port 80 (ISP blocking port 80).

And it works fine when starting using python headphones.py

@eangulus
Copy link
Author

eangulus commented Nov 5, 2014

Oh and what is this about:

05-Nov-2014 13:55:43 - INFO :: MainThread : Starting Headphones web server on http://http://gbqynekzsvdy.com/:8181/

@basilfx
Copy link
Contributor

basilfx commented Nov 5, 2014

The value http://http://gbqynekzsvdy.com/:8181/ is directly set from here, which is read directly from the config. Based on that, I think your configuration is not valid. Can you check your config.ini? Mine looks like this (only the relevant settings shown):

[General]
...
http_port = 9005
http_host = 0.0.0.0
http_username = ""
http_password = ""
http_root = /
http_proxy = 0
...

@basilfx basilfx added the Support label Nov 5, 2014
@eangulus
Copy link
Author

eangulus commented Nov 6, 2014

OK cool. Got it fixed. That weird URL was in the /opt/headphones/config.ini file/

I have attached a copy of the old config, as more so out of curiosity, there are heaps of weird stuff in there that shouldn't be and I was wondering if anyone can advise what might have happened so I can try to prevent it from happening again.

[General]
config_version = 5
http_port = http://gbqynekzsvdy.com/
http_host = http://gbqynekzsvdy.com/
http_username = http://gbqynekzsvdy.com/
http_password = ""
http_root = /
http_proxy = 0
enable_https = 0
https_cert = http://gbqynekzsvdy.com/
https_key = http://gbqynekzsvdy.com/
launch_browser = 0
api_enabled = 1
api_key = aca2f3490dd21f9595bd7c3bb023b69b
log_dir = /opt/headphones/logs
cache_dir = /opt/headphones/cache
git_path = ""
git_user = rembo10
git_branch = master
do_not_override_git_branch = 0
check_github = 1
check_github_on_startup = 1
check_github_interval = 360
music_dir = /mnt/STORAGE/MEDIA/AUDIO/MUSIC
destination_dir = /mnt/STORAGE/MEDIA/AUDIO/MUSIC
lossless_destination_dir = lgmPcUCwZDit
preferred_quality = 2
preferred_bitrate = 256
preferred_bitrate_high_buffer = RbINhoxQPuXJgpX
preferred_bitrate_low_buffer = XODGcNlCJ
preferred_bitrate_allow_lossless = 0
detect_bitrate = 0
lossless_bitrate_from = xnakrxy
lossless_bitrate_to = LikHZWFCihfCRMFYvHa
auto_add_artists = 1
correct_metadata = 1
move_files = 1
rename_files = 1
folder_format = $First/$Artist/$Year - $Album
file_format = $Track - $Title
file_underscores = 0
cleanup_files = 1
keep_nfo = 0
add_album_art = 1
album_art_format = $Artist - $Album
embed_album_art = 1
embed_lyrics = 0
replace_existing_folders = 1
nzb_downloader = 1
torrent_downloader = 1
download_dir = /mnt/STORAGE/DOWNLOADS/COMPLETED/MUSIC
blackhole_dir = htFgdUmLSbrOAUoQhmF
usenet_retention = 1500
include_extras = 0
extras = "3,4,5"
autowant_upcoming = 1
autowant_all = 0
keep_torrent_files = 0
prefer_torrents = 1
open_magnet_links = 0
numberofseeders = 10
torrentblackhole_dir = cdTnKDAcLNLbNkqqk
download_torrent_dir = /mnt/STORAGE/DOWNLOADS/COMPLETED/MUSIC
search_interval = 1440
libraryscan = 1
libraryscan_interval = 300
download_scan_interval = 5
update_db_interval = 24
mb_ignore_age = 365
preferred_words = 'eZJmRm  <a href="http://irfhiilgztpx.com/">irfhiilgztpx</a>, [url=http://pytsnwpylodm.com/]pytsnwpylodm[/url], [link=http://azfrntemdduk.com/]azfrntemdduk[/link], http://baqyjgdahlbd.com/'
ignored_words = 'eZJmRm  <a href="http://irfhiilgztpx.com/">irfhiilgztpx</a>, [url=http://pytsnwpylodm.com/]pytsnwpylodm[/url], [link=http://azfrntemdduk.com/]azfrntemdduk[/link], http://baqyjgdahlbd.com/'
required_words = 'eZJmRm  <a href="http://irfhiilgztpx.com/">irfhiilgztpx</a>, [url=http://pytsnwpylodm.com/]pytsnwpylodm[/url], [link=http://azfrntemdduk.com/]azfrntemdduk[/link], http://baqyjgdahlbd.com/'
lastfm_username = ""
interface = default
folder_permissions = 0755
file_permissions = 0644
music_encoder = 0
encoder = ffmpeg
xldprofile = NGNajPapGenxh
bitrate = 256
samplingfrequency = 44100
encoder_path = cLPGIGXmrwg
advancedencoder = ZslluGSXMNR
encoderoutputformat = mp3
encoderquality = 2
encodervbrcbr = cbr
encoderlossless = 0
encoder_multicore = 0
encoder_multicore_count = 0
delete_lossless_files = 0
mirror = headphones
customhost = localhost
customport = xnakrxy
customsleep = 1
hpuser = xnakrxy
hppass = De81042117
[Kat]
kat = 0
kat_proxy_url = http://gbqynekzsvdy.com/
kat_ratio = mhkLbOCdjhYFNwoOruS
[Mininova]
mininova = 0
mininova_ratio = gEkhylzaVidnUEGpLLn
[Piratebay]
piratebay = 0
piratebay_proxy_url = http://gbqynekzsvdy.com/
piratebay_ratio = zJSNejUGrpkDA
[Waffles]
waffles = 0
waffles_uid = xnakrxy
waffles_passkey = ""
waffles_ratio = lCpmsJCmnIBfzmFVO
[Rutracker]
rutracker = 0
rutracker_user = xnakrxy
rutracker_password = ""
rutracker_ratio = jNStqqXbhFHcmKlmxP
[What.cd]
whatcd = 0
whatcd_username = xnakrxy
whatcd_password = ""
whatcd_ratio = yxajpqFCHqfnwC
[SABnzbd]
sab_host = adYnCTkP
sab_username = xnakrxy
sab_password = ""
sab_apikey = ZjWDjbEgT
sab_category = oAAzWinMTVcL
[NZBget]
nzbget_username = xnakrxy
nzbget_password = ""
nzbget_category = AoFYIwVlIjLMIi
nzbget_host = PtnZVkbykjCU
nzbget_priority = 0
[Headphones]
headphones_indexer = 1
[Transmission]
transmission_host = http://localhost:9091
transmission_username = xnakrxy
transmission_password = ""
[uTorrent]
utorrent_host = cHmZGSZbeJcuZlO
utorrent_username = xnakrxy
utorrent_password = ""
utorrent_label = UAexKCndZJno
[Newznab]
newznab = 0
newznab_host = zUSFzxvdGL
newznab_apikey = ULDbjpyFyyxIEtpH
newznab_enabled = 1
extra_newznabs = ,
[NZBsorg]
nzbsorg = 0
nzbsorg_uid = None
nzbsorg_hash = XeUJSZrhqQpldiG
[omgwtfnzbs]
omgwtfnzbs = 0
omgwtfnzbs_uid = xnakrxy
omgwtfnzbs_apikey = nPAEZsLVJhl
[Growl]
growl_enabled = 0
growl_host = KfmexodyMMNmIK
growl_password = ""
growl_onsnatch = 0
[Prowl]
prowl_enabled = 0
prowl_keys = aNfEkKeprhcPLqv
prowl_onsnatch = 0
prowl_priority = 0
[XBMC]
xbmc_enabled = 0
xbmc_host = exVTsEmLptQTbUgBhm
xbmc_username = xnakrxy
xbmc_password = ""
xbmc_update = 0
xbmc_notify = 0
[LMS]
lms_enabled = 0
lms_host = kAfXcJwwRuDjDTFJdU
[Plex]
plex_enabled = 0
plex_server_host = eZMtQBCYnfhCMKtLm
plex_client_host = qHHbYmpwCunPdCHhE
plex_username = xnakrxy
plex_password = ""
plex_update = 0
plex_notify = 0
[NMA]
nma_enabled = 0
nma_apikey = aelGGgeimCtJH
nma_priority = -1
nma_onsnatch = 0
[Pushalot]
pushalot_enabled = 0
pushalot_apikey = APqBhxkiJqSi
pushalot_onsnatch = 0
[Pushover]
pushover_enabled = 0
pushover_keys = qHpvvzXgBWSAlTsRa
pushover_onsnatch = 0
pushover_priority = 0
pushover_apitoken = abTNEXYFUIDVuB
[PushBullet]
pushbullet_enabled = 1
pushbullet_apikey = v1eAM0AeVmGzR6G0JxK1mJktqSH5kBxJFDujxPLjF3Dc4
pushbullet_deviceid = xnakrxy
pushbullet_onsnatch = 1
[Twitter]
twitter_enabled = 0
twitter_onsnatch = 0
twitter_username = etAZYS3ocvFfKm65TgzyOIBA9V4yVZF2
twitter_password = 9k06wSahOcqV0r7db6EQM7kMdQmZviiD
twitter_prefix = Headphones
[OSX_Notify]
osx_notify_enabled = 0
osx_notify_onsnatch = 0
osx_notify_app = /Applications/Headphones
[Boxcar]
boxcar_enabled = 0
boxcar_onsnatch = 0
boxcar_token = LbVCcxJC
[Songkick]
songkick_enabled = 0
songkick_apikey = nd1We7dFW2RqxPw8
songkick_location = vShIjvsDKddm
songkick_filter_enabled = 0
[Synoindex]
synoindex_enabled = 0
[Advanced]
album_completion_pct = 80
cache_sizemb = 64
journal_mode = wal
verify_ssl_cert = 1

@basilfx
Copy link
Contributor

basilfx commented Nov 6, 2014

Good to hear, but the weird URLs look like they were added/set by some virus or something.

@eangulus
Copy link
Author

eangulus commented Nov 7, 2014

But what virus would have affected this?

Never had virus's on Linux before. Its a Ubuntu Headless Server that is dedicated ONLY to Couchpotato, Headphones, Sickbeard with File sharing and thats it.

@eangulus
Copy link
Author

eangulus commented Nov 7, 2014

To me it looks more like some sort of corruption.

@basilfx
Copy link
Contributor

basilfx commented Nov 7, 2014

Yes, it's corruption. But all keys, tokens, usernames and passwords look encrypted. And the host name/strange url is typical a spammer domain. Something caused that.

@eangulus
Copy link
Author

eangulus commented Nov 7, 2014

But like what? I just can't wrap my head around that a headless system, that is never used directly and therefore does not run anything other than what I originally setup.

If I can get an idea on how it could have happened or something, I can then look for the files or check the security of the box. This box has only been running for around 3 months, and hasn't even got custom repositories. Everything is, or near stock. I installed Ubuntu Server with minimal features, setup a LVM, installed the headphones and couch and sickbeard, setup Samba and Apache and installed webmin, transmission, and only have webmin and transmission ports open on the router.

Can anyone give any guide on what files to search for or things to check. I am just concerned that leaving it be might mean it can occur again.

@basilfx
Copy link
Contributor

basilfx commented Nov 7, 2014

I wish I could give a hint to what might have caused it. Maybe it's good to run a virus scanner once, and see if some malware and/or viruses are still on the system.

Do not that I am not 100% sure that it is a virus. I only draw this conclusion from what I see in your config file that looks unnatural. Maybe you downloaded a copy of Headphones from an untrusted source, with a pre-defined config.ini in it? Maybe someone hacked into your system, or from another system in the network? Maybe it was something that occurred only once, and nothing is going on anymore? Just speculating

@eangulus
Copy link
Author

eangulus commented Nov 7, 2014

I understand all that, I can eliminate some of those options but not all.

What do you recommend to use to do a scan on Ubunutu Server? Never needed to do one before.

Figure I can do a scan and leave it at that. Maybe turn on some extra logging on the router just to have something to look for if it ever happened again.

@eangulus
Copy link
Author

eangulus commented Nov 7, 2014

Thanks BTW, for your help. I knew it was just a matter of deduction but I got to the end of what I knew and didn't know where to check next.

@basilfx
Copy link
Contributor

basilfx commented Nov 7, 2014

I don't know any good virus scanners because I haven't used one before either :-P But I guess there should be a free one in apt-get, somewhere. Google probably knows it :)

I am closing this issue now.

@basilfx basilfx closed this as completed Nov 7, 2014
@eangulus
Copy link
Author

eangulus commented Nov 7, 2014

Just a heads up. I have confirmed a hack.

Not sure how yet, but it happened again, only this time instead of jumbled letters, they wrote in the username section "your site has been breached".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants