1. How to speak Perl
cPanel
Todd Rinaldo - cPanel Developer
2. /scripts/upcp
• Honors /etc/cpupdate.conf for if it's enabled
• UPDATES=automatic / manual / never
• Downloads a new version of cPanel
• Does post-update tasks - /scripts/post_sync_cleanup
• does daily /scripts/maintenance tasks
3. /scripts/updatenow
• Updates needed files for version you are switching to
• Uses cpanelsync protocol
• Stage before commit (11.36)
• Installs needed RPMs for version you're switching to
• NEVER call this directly
4. cpanelsync
• Rsync Protocol?
• uses a data file (.cpanelsync) to decide what needs
updating
• Only downloads what is new vs EVERYTHING if cPanel
used RPMs for this.
5. updatenow details
• New version? If not STOP.
• Download the new updatenow.static
• stage all files (compressed) next to where they'll go (cpsrvd-cpanelsync)
• stage all cpanel-* rpms to /ULC/tmp/rpm_downloads
• RPM transaction test?
• ********* DANGER WILL ROBINSON! *********
• Put files in place (mv cpsrvd.cpanelsync cpsrvd)
• Staged to alternate path sometimes.
• Install RPMs
10. Cpanel::
• Original name space (/usr/local/cpanel/Cpanel)
• Originally meant as a API for customers to invoke from
cPanel pages.
• Today stores code related to end user interfaces
• Default for misc stuff
• Cpanel/Unix/PID/Tiny.pm
25. Shrink your program
memory size.
• Package removal during C code generation
• COW strings stored as C strings
• duplicates consolidated to 1 string.
• Strings, Arrays, Hashes optimized to perfect size.
35. Cpanel::LoadModule
• Loads code at runtime.
• Used for rarely needed code paths.
• Reduces code size at startup
• Cpanel::LoadModule::load_perl_module('Cpanel::Email::Privs');
36. Cpanel::Config::CpConfGuard
• Interface for /var/cpanel/cpanel.config
• Data validated on save (mostly)
• Most accessors via alternate interface (legacy)
• Cpanel::Config::LoadCpConf::loadcpconf()
37. CpConfGuard Read
• my $hash_ref = Cpanel::Config::LoadCpConf::loadcpconf()
• print "Success" if $hash_ref->{‘mysql-version'}
39. Cpanel::Binaries
• Tracks the location of 3rdparty binaries, often shipped as
cPanel RPMS.
• Reliable across multiple versions of cPanel
$>perl -MCpanel::Binaries -E'say
Cpanel::Binaries::get_binary_location("perl")'
/usr/local/cpanel/3rdparty/perl/524/bin/perl
40. Cpanel::GenSysInfo
• Provides RPM and distro information about the local
system
• Cached for performance - /var/cpanel/sysinfo.config
• Cpanel::GenSysInfo::get_rpm_distro_version() # 7
• C::GSI::get_system_release_file() # /etc/redhat-release
• Cpanel::GenSysInfo::get_rpm_distro() # centos
41. Cpanel::TempFile
• Creates Temp files that are removed when the object
goes out of scope
• Not fork safe
• my $temp_obj = Cpanel::TempFile->new();
• my ( $file_name, $file_handle ) = $temp_obj->file();
• close $file_handle;