diff --git a/admin/app/admin/icecast_bootstrap.rb b/admin/app/admin/icecast_bootstrap.rb index 3b3f643b6..5a87155d7 100644 --- a/admin/app/admin/icecast_bootstrap.rb +++ b/admin/app/admin/icecast_bootstrap.rb @@ -62,11 +62,11 @@ ActiveAdmin.register_page "Bootstrap" do logging.save! listen_socket1 = IcecastListenSocket.new - listen_socket1.port = 8000 + listen_socket1.port = 9000 listen_socket1.save! listen_socket2 = IcecastListenSocket.new - listen_socket2.port = 8001 + listen_socket2.port = 9001 listen_socket2.save! template = IcecastTemplate.new @@ -86,6 +86,72 @@ ActiveAdmin.register_page "Bootstrap" do redirect_to admin_bootstrap_path, :notice => "Brew template created. Now, create a mount template." end + page_action :ubuntu_template, :method => :post do + # to make this template, I installed icecast233 from jenkins (or our chef'ed apt-repo, same difference), and then based the rest of this code on what I saw in /etc/icecast2/icecast.xml + + IcecastServer.transaction do + + limit = IcecastLimit.new + limit.clients = 100 + limit.sources = 2 + limit.queue_size = 524288 + limit.client_timeout = 30 + limit.header_timeout = 15 + limit.source_timeout = 10 + limit.burst_size = 65535 + limit.save! + + admin_auth = IcecastAdminAuthentication.new + admin_auth.source_pass = 'blueberryjam' + admin_auth.relay_user = 'jamjam' + admin_auth.relay_pass = 'blueberryjam' + admin_auth.admin_user = 'jamjam' + admin_auth.admin_pass = 'blueberryjam' + admin_auth.save! + path = IcecastPath.new + path.base_dir = '/usr/share/icecast2' + path.log_dir = '/var/log/icecast2' + path.web_root = '/usr/share/icecast2/web' + path.admin_root = '/usr/share/icecast2/admin' + path.pid_file = nil + path.save! + + security = IcecastSecurity.new + security.chroot = false + security.save! + + logging = IcecastLogging.new + logging.access_log = 'access.log' + logging.error_log = 'error.log' + logging.log_level = 3 # you might want to change this after creating the template + logging.log_size = 10000 + logging.save! + + listen_socket1 = IcecastListenSocket.new + listen_socket1.port = 9000 + listen_socket1.save! + + listen_socket2 = IcecastListenSocket.new + listen_socket2.port = 9001 + listen_socket2.save! + + template = IcecastTemplate.new + template.name = "Ubuntu-#{IcecastTemplate.count + 1}" + template.location = '@work' + template.admin_email = 'nobody@jamkazam.com' + template.fileserve = true + template.limit = limit + template.admin_auth = admin_auth + template.path = path + template.security = security + template.logging = logging + template.listen_sockets = [listen_socket1, listen_socket2] + template.save! + end + + redirect_to admin_bootstrap_path, :notice => "Ubuntu 12.04 template created. You should also install the icecast233 package: https://int.jamkazam.com/jenkins/job/icecast-debian/" + end + page_action :create_mount_template, :method => :post do IcecastServer.transaction do hostname = params[:jam_ruby_icecast_mount_template][:hostname] @@ -102,7 +168,7 @@ ActiveAdmin.register_page "Bootstrap" do auth.save! mount_template = IcecastMountTemplate.new - mount_template.name = "#{type}-#{IcecastMountTemplate.count}" + mount_template.name = "#{type}-#{IcecastMountTemplate.count + 1}" mount_template.source_username = nil # mount will override mount_template.source_pass = nil # mount will override mount_template.max_listeners = 20000 # huge @@ -143,6 +209,11 @@ ActiveAdmin.register_page "Bootstrap" do link_to "Create MacOSX (Brew) Template", admin_bootstrap_brew_template_path, :method => :post end + action_item do + link_to "Create Ubuntu 12.04 Template", admin_bootstrap_ubuntu_template_path, :method => :post + end + + content do if IcecastTemplate.count == 0 diff --git a/ruby/lib/jam_ruby/models/icecast_server.rb b/ruby/lib/jam_ruby/models/icecast_server.rb index 4cc3bd23d..69145e92b 100644 --- a/ruby/lib/jam_ruby/models/icecast_server.rb +++ b/ruby/lib/jam_ruby/models/icecast_server.rb @@ -4,7 +4,8 @@ module JamRuby attr_accessor :skip_config_changed_flag attr_accessible :template_id, :mount_template_id, :limit_id, :admin_auth_id, :directory_id, :master_relay_id, :path_id, :logging_id, - :security_id, :config_changed, :hostname, :location, :admin_email, :fileserve, as: :admin + :security_id, :config_changed, :hostname, :location, :admin_email, :fileserve, :icecast_server_group_id, as: :admin + belongs_to :template, class_name: "JamRuby::IcecastTemplate", foreign_key: 'template_id', inverse_of: :servers belongs_to :mount_template, class_name: "JamRuby::IcecastMountTemplate", foreign_key: 'mount_template_id', inverse_of: :servers diff --git a/ruby/lib/jam_ruby/models/invited_user.rb b/ruby/lib/jam_ruby/models/invited_user.rb index 385347d34..6481a6bdb 100644 --- a/ruby/lib/jam_ruby/models/invited_user.rb +++ b/ruby/lib/jam_ruby/models/invited_user.rb @@ -4,6 +4,7 @@ module JamRuby VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i attr_accessible :email, :sender_id, :autofriend, :note, as: :admin + attr_accessor :accepted_twice self.primary_key = 'id' diff --git a/web/config/application.rb b/web/config/application.rb index e6394999e..4da7d5464 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -171,7 +171,7 @@ include JamRuby config.audiomixer_path = "/var/lib/audiomixer/audiomixer/audiomixerapp" # if it looks like linux, use init.d script; otherwise use kill - config.icecast_reload_cmd = ENV['ICECAST_RELOAD_CMD'] || (File.exist?('/usr/bin/icecast2') ? '/etc/init.d/icecast2 reload' : "bash -l -c #{Shellwords.escape("kill -1 `ps -f | grep /usr/local/bin/icecast | grep -v grep | awk \'{print $2}\'`")}") + config.icecast_reload_cmd = ENV['ICECAST_RELOAD_CMD'] || (File.exist?('/usr/local/bin/icecast2') ? "bash -l -c #{Shellwords.escape("sudo /etc/init.d/icecast2 reload")}" : "bash -l -c #{Shellwords.escape("kill -1 `ps -f | grep /usr/local/bin/icecast | grep -v grep | awk \'{print $2}\'`")}") # if it looks like linux, use that path; otherwise use the brew default path config.icecast_config_file = ENV['ICECAST_CONFIG_FILE'] || (File.exist?('/etc/icecast2/icecast.xml') ? '/etc/icecast2/icecast.xml' : '/usr/local/etc/icecast.xml') # this will be the qualifier on the IcecastConfigWorker queue name